コード例 #1
0
ファイル: csv.php プロジェクト: osw17/oledrion
 /**
  * Export des données
  * @return boolean Vrai si l'export a réussi sinon faux
  */
 function export()
 {
     $file = $this->folder . DIRECTORY_SEPARATOR . $this->filename;
     $fp = fopen($file, 'w');
     if (!$fp) {
         $this->success = false;
         return false;
     }
     // Création de l'entête du fichier
     $list = $entete1 = $entete2 = array();
     $s = $this->separator;
     $cmd = new oledrion_commands();
     foreach ($cmd->getVars() as $fieldName => $properties) {
         $entete1[] = $fieldName;
     }
     // Ajout des infos de caddy
     $cart = new oledrion_caddy();
     foreach ($cart->getVars() as $fieldName => $properties) {
         $entete2[] = $fieldName;
     }
     $list[] = array_merge($entete1, $entete2);
     // make item array
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('cmd_id', 0, '<>'));
     $criteria->add(new Criteria('cmd_state', $this->orderType, '='));
     $criteria->setSort('cmd_date');
     $criteria->setOrder('DESC');
     $orders = $this->handlers->h_oledrion_commands->getObjects($criteria);
     foreach ($orders as $order) {
         $carts = array();
         $carts = $this->handlers->h_oledrion_caddy->getObjects(new Criteria('caddy_cmd_id', $order->getVar('cmd_id'), '='));
         $ligne = array();
         foreach ($carts as $cart) {
             $ligne = array();
             foreach ($entete1 as $commandField) {
                 $ligne[] = $order->getVar($commandField);
             }
             foreach ($entete2 as $cartField) {
                 $ligne[] = $cart->getVar($cartField);
             }
             // Add to main array
             $list[] = $ligne;
         }
     }
     // import information on csv file
     foreach ($list as $fields) {
         fputcsv($fp, $fields);
     }
     fclose($fp);
     $this->success = true;
     return true;
 }
コード例 #2
0
 /**
  * Marque un caddy comme ayant été téléchargé
  *
  * @param oledrion_caddy $caddy
  * @return boolean	Le résultat de la mise à jour
  */
 function markCaddyAsNotDownloadableAnyMore(oledrion_caddy $caddy)
 {
     $caddy->setVar('caddy_pass', '');
     return $this->insert($caddy, true);
 }