Exemple #1
0
 /**
  * Export data
  * @return boolean
  */
 function export()
 {
     $fp = fopen($this->folder . DIRECTORY_SEPARATOR . $this->filename, 'w');
     if (!$fp) {
         $this->success = false;
         return false;
     }
     // Creation of file header
     $entete1 = $entete2 = array();
     $s = $this->separator;
     $cmd = new myshop_commands();
     foreach ($cmd->getVars() as $fieldName => $properties) {
         $entete1[] = $fieldName;
     }
     // Addcart info
     $cart = new myshop_caddy();
     foreach ($cart->getVars() as $fieldName => $properties) {
         $entete2[] = $fieldName;
     }
     fwrite($fp, implode($s, array_merge($entete1, $entete2)) . "\n");
     $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_myshop_commands->getObjects($criteria);
     foreach ($orders as $order) {
         $carts = array();
         $carts = $this->handlers->h_myshop_caddy->getObjects(new Criteria('caddy_cmd_id', $order->getVar('cmd_id'), '='));
         $ligne = array();
         foreach ($carts as $cart) {
             foreach ($entete1 as $commandField) {
                 $ligne[] = $order->getVar($commandField);
             }
             foreach ($entete2 as $cartField) {
                 $ligne[] = $cart->getVar($cartField);
             }
         }
         fwrite($fp, implode($s, $ligne) . "\n");
     }
     fclose($fp);
     $this->success = true;
     return true;
 }
Exemple #2
0
 /**
  * Set cart as downloaded
  *
  * @param myshop_caddy $caddy
  * @return boolean
  */
 function markCaddyAsNotDownloadableAnyMore(myshop_caddy $caddy)
 {
     $caddy->setVar('caddy_pass', '');
     return $this->insert($caddy, true);
 }