Esempio n. 1
0
 public function viewOrderAction()
 {
     // web page title
     $this->view->title = "Résumé de la commande";
     $orderId = $this->_getParam('ID');
     $redirectTo = "/order/index/list-orders/";
     if (!empty($orderId)) {
         $details = array();
         $oOrder = new OrderObject();
         $details = $oOrder->populate($orderId, $this->_defaultEditLanguage);
         $form = new FormViewOrder(array('cancelUrl' => "{$this->view->baseUrl()}{$redirectTo}", 'disabledSaveAction' => true, 'data' => $details));
         $this->view->assign('form', $form);
     }
 }
Esempio n. 2
0
 public function writeFile()
 {
     $session = new Zend_Session_Namespace('order');
     $db = Zend_Registry::get('db');
     $startDate = date('d-m-Y H:i:s');
     $string = "--------- Export starting date: " . $startDate . "--------- \r\n";
     $this->writeLog($string);
     $this->orderExportPath = Zend_Registry::get('web_root') . "/data/files/order/export/";
     $columns = array();
     $oOrder = new OrderObject();
     $oOrderLine = new OrderLinesObject();
     $nbOrder = 0;
     $totLines = 0;
     $tableName = $oOrder->getDataTableName();
     $orderHeader = 'O_ID, DATE(O_CreateDate), O_Email, CONCAT(O_FirstBillingAddr, " ", O_SecondBillingAddr), CONCAT(O_BillingCity," - ",O_BillingState), "CA" as ISOCodeBill, O_ZipCode, ';
     $orderHeader .= 'CONCAT(O_FirstShippingAddr, " ", O_SecondShippingAddr), CONCAT(O_ShippingCity," - ", O_ShippingState), "CA" as ISOCodeShip, O_ShippingZipCode, "Transaction par panier d achat" as Label, O_TransFees, ';
     $orderHeader .= "O_Total, O_CardType, null as NAN, '{$session->customer['identification']['taxCode']}' as taxCode";
     $orderFooter = array('O_Notes', 'O_FirstBillingTel', 'concat(O_FirstName, " ", O_LastName)', 'O_AcombaId');
     //        $orderFooter .= 'O_AcombaId';
     $LineColumns = array('OL_ProductCode', 'OL_Description', 'OL_Quantity', 'OL_Price');
     $orders = $oOrder->getDataForExport($orderHeader, self::STATUS);
     foreach ($orders as $order) {
         $orderId = $order['O_ID'];
         // Define variables to fill export file
         $fileLine = "";
         $nbLines = 0;
         $fileName = $tableName . self::UNDERSCORE . $orderId . self::EXTENSION;
         $file = $_SERVER['DOCUMENT_ROOT'] . $this->orderExportPath . $fileName;
         //Open file to write data into it.
         $fh = fopen($file, 'w');
         // Prepare header data
         if (isset($session->order['cod'])) {
             $order['O_TransFees'] = $order['O_TransFees'] + $session->order['CODFees'];
         }
         $header = implode(self::SEPARATOR, $order);
         // Prepaqre footer data
         $footData = $oOrder->getDataForExport($orderFooter, self::STATUS, $orderId);
         $tel = str_replace(array('(', ')', ' ', '-'), array('', '', '', ''), $footData[0]['O_FirstBillingTel']);
         // Set the values in new array ordered to fit with sql
         $footDt['O_Notes'] = $footData[0]['O_Notes'];
         $footDt['Empty'] = 'F';
         $footDt['O_FirstBillingTel'] = $tel;
         $footDt['Name'] = $footData[0]['concat(O_FirstName, " ", O_LastName)'];
         $footDt['O_AcombaId'] = $footData[0]['O_AcombaId'];
         $footer = implode(self::SEPARATOR, $footDt);
         // Select related lines
         $lines = $oOrderLine->getDataForExport($orderId, $LineColumns);
         foreach ($lines as $line) {
             ++$nbLines;
             $lineData = $nbLines . self::SEPARATOR;
             array_push($line, "");
             array_push($line, "");
             $lineData .= implode(self::SEPARATOR, $line);
             $fileLine .= $header . self::SEPARATOR . $lineData . self::SEPARATOR . $footer . "\r\n";
         }
         if (!$fh) {
             $string = 'Cannot open ' . $file . ' at ' . date('d-m-Y H:i:s');
             $this->writeLog($string);
         } else {
             $this->writeData($fh, $fileLine);
             //Colse the file;
             fclose($fh);
             ++$nbOrder;
             $totLines += $nbLines;
             $status = array('O_Status' => 'exportee');
             $oOrder->save($orderId, $status, 1);
             $endDate = date('d-m-Y H:i:s');
             $string = $endDate;
             $string .= " : " . $fileName . ' - ' . $nbLines . " lines(products) exported\r\n";
             $this->writeLog($string);
         }
     }
 }