from($table)->where($identifiant.' = ?', substr($num,1)); if (!hasModeEdition()){ $q->andWhere('login = ?', $_SESSION['tabInfo']['login']); } $commandes = $q->execute(); $outputCommandes = array(); foreach ($commandes as $commande){ if (filtreIdentifiantCommande($num, $commande)){ $outputCommandes[] = $commande; } } //Recherche par numéro siren et type de commande } elseif (!empty($siren)) { $table = tableTypeCommande($type); $q->from($table)->where('siren = ?', $siren); if (!hasModeEdition()){ $q->andWhere('login = ?', $_SESSION['tabInfo']['login']); } } $commandes = $q->execute(); //Résultat return $commandes; } function filtrage(){ } function filtreIdentifiantCommande($num, $commande){ $return = false; switch(substr($num,0,1)){ case 'G': if ($commande->typeCommande == 'G' || $commande->typeCommande == ''){ $return = true; } break; case 'C': if ($commande->typeCommande == 'C'){ $return = true; } break; } return $return; } function filtreTypeCommande($type, $ref){ $return = false; switch($type){ case 'greffe-actes': if (preg_match('/^([0-9a-zA-Z]{2}-).*?$/', $ref, $matches)){ $return = true; } break; case 'greffe-bilans': if (preg_match('/^([0-9]{4}_).*?$/', $ref, $matches)){ $return = true; } break; case 'greffe-kbis': break; case 'greffe-priv': break; } return $return; } function tableNumCommande($num){ switch(substr($num,0,1)){ case 'G': case 'C': $table = 'Commandes'; break; } return $table; } function identifiantTable($nomTable){ switch($nomTable){ case 'Commandes': $identifiant = 'idCommande'; break; case 'CommandesPieces': $identifiant = 'id'; break; case 'CommandesKbis': $identifiant = 'id'; break; } return $identifiant; } function tableTypeCommande($type){ switch($type){ case 'greffe-actes': case 'greffe-bilans': $table = 'Commandes'; break; case 'greffe-kbis': $table = 'CommandesKbis'; break; case 'greffe-priv': $table = 'CommandesPieces'; break; } return $table; } function documentLib($ref, $info, $type){ global $typeActes; $lib = 'Inconnu'; switch($type){ case 'greffe': if (preg_match('/^([0-9a-zA-Z]{2}-).*?$/', $ref, $matches)){ if (substr($ref,0,3)=='ST-'){ $lib = 'DERNIER STATUS À JOUR'; } else { $explodedRef = explode('-', $ref); $date = new WDate(); $dateref = $date->dateT('Ymd','d/m/Y',$explodedRef[1]); $depot = ', Dépôt n°'.$explodedRef[6].' au '.$dateref; $lib = $typeActes['a'.substr($ref,0,2)].$depot; } } elseif (preg_match('/^([0-9]{4}).*?$/', $ref, $matches)){ $lib = 'Bilan de '.$matches[1]; } break; } return $lib; } function documentInfo($ref, $info, $type){} function documentFilename($siren, $ref, $type){ $filename = ''; switch($type){ case 'greffe': if (preg_match('/^([0-9a-zA-Z]{2}-).*?$/', $ref, $matches)){ $filename = infogreffe_acte_filename($siren, $ref); } elseif (preg_match('/^([0-9]{4}).*?$/', $ref, $matches)){ $filename = infogreffe_bilan_filename($siren, $ref); } break; } return $filename; } function documentLienExtranet($siren, $ref, $type){ $lien = '#'; switch($type){ case 'greffe': if (preg_match('/^([0-9a-zA-Z]{2}-).*?$/', $ref, $matches)){ $lien = './?page=greffes&vue=actes&siret='.$siren; FB::log(''); } elseif (preg_match('/^([0-9]{4}).*?$/', $ref, $matches)){ $lien = './?page=greffes&vue=bilans&siret='.$siren; } break; } return $lien; } function documentStatut($commande){ $statut = 'En cours...'; if ($commande->dateReception != '0000-00-00 00:00:00'){ $statut = 'Envoyé'; } if ($commande->statutCommande==9 && $commande->dateReception=='0000-00-00 00:00:00'){ $statut = 'Erreur'; } return $statut; } /** * * @param unknown_type $type * @param unknown_type $etat * @param unknown_type $date */ function commandesListe($type, $etat, $date, $mode = ''){ setDbConn('sdv1'); $table = tableTypeCommande($type); $dateTDebut = mktime(0, 0, 0, date('m', $date), 1, date('Y', $date)); $dateDebut = date('Y-m',$dateTDebut); $q = Doctrine_Query::create() ->from($table) ->Where('dateCommande LIKE ? ', $dateDebut.'%'); if (preg_match('/([A-Z])-([0-9]{1,})/', $etat, $matches)){ $q->andWhere('statutCommande = ?', $matches[2]); } else { switch($etat){ case 'commande': $q->andWhere('statutCommande != ?', 9); $q->andWhere('dateReception = ?', '0000-00-00 00:00:00'); break; case 'reception': $q->andWhere('dateReception != ?', '0000-00-00 00:00:00'); break; case 'erreur': $q->andWhere('statutCommande = ?', 9); $q->andWhere('dateReception = ?', '0000-00-00 00:00:00'); break; } } if ( $mode!='-' ){ if ( $mode == 'G' ) { $q->andWhereIn('typeCommande', array('', $mode)); } else { if ( $table == 'CommandesKbis' || $table == 'CommandesPieces' ){ $q->andWhere('type = ?', $mode); } else { $q->andWhere('typeCommande = ?', $mode); } } } if ( !hasModeEdition() ){ $q->andWhere('login = ?', $_SESSION['tabInfo']['login']); } FB::log($q->getSqlQuery(), 'QUERY'); FB::log($q->getFlattenedParams(), 'PARAMS'); //Résultat $commandes = $q->execute(); return $commandes; } function listStatus(){ $q = Doctrine_Query::create() ->from('CommandesStatut') ->where('typeCommande = ?', 'C') ->orderBy('ordre ASC'); $cStatuts = $q->execute(); return $cStatuts; } /** * Retourne la raison sociale à partir du siren * @param unknown_type $siren */ function raisonSociale($siren){ global $client; $rs = 'Obtenir la raison sociale'; return $rs; } /** * Retourne le contenu HTML pour l'affichage de la commande * @param array $commande * @param array $type */ function afficheCommande($commande, $type){ static $compteur = 0; $output = ''; switch ($type) { /* * Traitement de l'affichage des kbis par email ou courrier */ case 'greffe-kbis': FB::log($commande->id, 'commande'); $colspan = 3; // Affichage if ($compteur%2){ $class = ' even'; }else{ $class = ' odd'; } $compteur++; // Formulaire pour modifier l'état d'une commande courrier S&D $contenuEtat = ''; if ( $commande->type=='C' && hasModeEdition() ){ $contenuEtat.= 'Générer le courrier'; } if ( ($commande->type=='C' || $commande->type='M') && hasModeEdition() ){ $cStatuts = listStatus(); $contenuEtat.= '