Exemple #1
0
 /**
  * import orders
  * @return boolean
  */
 public function importOrders()
 {
     $this->users = load_users();
     $this->products_i18n = load_products_i18n();
     if (isset($this->xml->СписокРасходныеНакладные)) {
         $statuses = array();
         foreach ($this->xml->СписокРасходныеНакладные as $status) {
             if ($status->IDЗаказПокупателя . '') {
                 $statuses[$status->IDЗаказПокупателя . ''] = array('id' => $status->ID . '', 'code' => $status->Номер . '', 'date' => strtotime($status->Дата . ''));
             }
         }
     }
     foreach ($this->xml->СписокЗаказыПокупателя as $order) {
         $data = array();
         $data['date_created'] = strtotime($order->Дата . '');
         $data['user_deliver_to'] = $order->Адрес . '';
         $data['user_phone'] = $order->КонтактныйТелефон . '';
         $data['paid'] = (int) $order->ПризнакПередоплаты;
         $data['external_id'] = $order->ID . '';
         $data['code'] = $order->Номер . '';
         $data['delivery_date'] = strtotime($order->СрокДоставки . '');
         $data['partner_external_id'] = $order->IDОрганизация . '';
         $data['status'] = 1;
         if ($statuses[$data['external_id']]) {
             $data['status'] = 2;
             $data['invoice_external_id'] = $statuses[$data['external_id']]['id'];
             $data['invoice_code'] = $statuses[$data['external_id']]['code'];
             $data['invoice_date'] = $statuses[$data['external_id']]['date'];
         }
         $user = is_user($order->IDКонтрагент, $this->users);
         if ($user) {
             $userInfo = $this->ci->db->where('id', $user['id'])->get('users')->row_array();
             $data['user_id'] = $user['id'];
             $data['user_full_name'] = $userInfo['username'];
             $data['user_email'] = $userInfo['email'];
         } else {
             return;
         }
         $order_exist = is_order($data['external_id'], $this->orders);
         if ((string) $order->IDWeb) {
             $data['id'] = (string) $order->IDWeb . '' ? (string) $order->IDWeb . '' : $order_exist['id'];
             foreach ($this->xml->СписокРасходныеНакладные as $status) {
                 if ((string) $status->IDЗаказПокупателя == $order->ID) {
                     $this->updateOrder($status, $data);
                     //                        var_dumps($status);
                     break;
                 }
             }
             //                $this->updateOrder($order, $data);
         } else {
             $this->insertOrder($order, $data);
         }
     }
     $this->insertData($this->orders_table);
     $this->updateData($this->orders_table, 'id');
     $inserted_orders = load_orders();
     foreach ($inserted_orders as $value) {
         foreach ($this->insert_order_products as $key => $order_product) {
             if ($order_product['external_order_id'] == $value['external_id'] && $order_product['external_order_id'] != NULL) {
                 $this->insert_order_products[$key]['order_id'] = $value['id'];
                 unset($this->insert_order_products[$key]['external_order_id']);
             }
         }
     }
     $this->insert = $this->insert_order_products;
     $this->insertData($this->orders_products_table);
     $this->updateData($this->orders_table, 'id');
     $this->update = $this->update_order_products;
     $this->updateData($this->orders_products_table, 'id');
 }
Exemple #2
0
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 * 
 * User Authentication Functions
 */
//------------------------------------------------------------------------------
require_once _EXT_PATH . "/include/users.php";
load_users();
//------------------------------------------------------------------------------
$GLOBALS['__SESSION'] =& $_SESSION;
if (!empty($_REQUEST['type'])) {
    $GLOBALS['authentication_type'] = basename(extGetParam($_REQUEST, 'type', $GLOBALS['ext_conf']['authentication_method_default']));
} else {
    $GLOBALS['authentication_type'] = $GLOBALS['file_mode'];
}
if ($GLOBALS['authentication_type'] == 'file') {
    $GLOBALS['authentication_type'] = 'extplorer';
}
if (!in_array($GLOBALS['authentication_type'], $GLOBALS['ext_conf']['authentication_methods_allowed'])) {
    $GLOBALS['authentication_type'] = extgetparam($_SESSION, 'file_mode', $GLOBALS['ext_conf']['authentication_method_default']);
    if (!in_array($GLOBALS['authentication_type'], $GLOBALS['ext_conf']['authentication_methods_allowed'])) {
        $GLOBALS['authentication_type'] = $_SESSION['file_mode'] = $GLOBALS['ext_conf']['authentication_method_default'];
    }
Exemple #3
0
 /**
  * import orders
  * @return boolean
  */
 public function importOrders()
 {
     $this->users = load_users();
     $this->products_i18n = load_products_i18n();
     foreach ($this->xml->СписокЗаказыПокупателя as $order) {
         $data = array();
         $data['date_created'] = strtotime($order->Дата . '');
         $data['user_deliver_to'] = $order->Адрес . '';
         $data['user_phone'] = $order->КонтактныйТелефон . '';
         $data['paid'] = (int) $order->ПризнакПередоплаты;
         $data['external_id'] = $order->ID . '';
         $data['partner_external_id'] = $order->IDОрганизация . '';
         $user = is_user($order->IDКонтрагент, $this->users);
         if ($user) {
             $data['user_id'] = $user['id'];
         } else {
             return false;
         }
         if (!is_order($order->ID, $this->orders)) {
             $this->insertOrder($order, $data);
         } else {
             $this->updateOrder($order, $data);
         }
     }
     $this->insertData($this->orders_table);
     $inserted_orders = load_orders();
     foreach ($inserted_orders as $value) {
         foreach ($this->insert_order_products as $key => $order_product) {
             if ($order_product['external_order_id'] == $value['external_id']) {
                 $this->insert_order_products[$key]['order_id'] = $value['id'];
                 unset($this->insert_order_products[$key]['external_order_id']);
             }
         }
     }
     $this->insert = $this->insert_order_products;
     $this->insertData($this->orders_products_table);
     $this->updateData($this->orders_table, 'external_id');
     $this->update = $this->update_order_products;
     $this->updateData($this->orders_products_table, 'external_id');
 }