public function getOrdersByIDUser($id) { $orders = new stdClass(); $orderfpp = new fpp_order_Model(); $orderorm = $orderfpp->db2cls(); $orders = $orderorm->fetch_where(array('client_id_client' => $id), 'id_order', 'DESC'); $r_oders = array(); foreach ($orders as $order) { $r_oders[$order->id_order] = $order; $datetime = date_format(date_create($order->date_order), 'd/m/Y'); $r_oders[$order->id_order]->date_order_formated = $datetime; } return $r_oders; }
function saveAndSendOrder($is2checkout = false) { $user = new fpp_client_Model(); $userdata = $user->db2cls((int) @$_SESSION['conf']['client']['id']); /*Only send email to client, previously saved and send to admin store*/ if (isset($_SESSION['previos_2checkout_email'])) { basics::mail_html_utf8($userdata->mail_client, __("Confirmación de Pedido", false), $_SESSION['previos_2checkout_email'], $this->mail_store, $this->config_store_name); unset($_SESSION['previos_2checkout_email']); } else { $total = $_SESSION['conf']['cart']['subtotal_noformat'] + $_SESSION['conf']['order']['district_price']; $_SESSION['conf']['total_req'] = $total; Basic::currency($total); $_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest'; $model = new fpp_order_Model(); $orm = $model->db2cls(); $id = (int) $_SESSION['conf']['client']['id']; $order = $_SESSION['conf']['order']; $subtotalall = $_SESSION['conf']['cart']['subtotal_noformat']; Basic::currency($subtotalall); $payment = new Paymentclass(); $paymentinfo = $payment->infomod($_SESSION['conf']['order']['payment_type']); $orm->set_fields(array('product_name_order' => $order['fname'] . ' ' . $order['lname'], 'client_id_client' => $id, 'product_address_order' => $order['address'], 'product_district_order' => $order['district_name'], 'product_infoextra_order' => $order['comments'], 'facturacion_name' => $order['fact_name'], 'facturacion_address' => $order['fact_address'], 'facturacion_ruc' => $order['fact_ruc'], 'deliverydate' => $order['delivery_date'], 'message' => $order['messagecard'], 'status_order' => "incompleto", 'date_order' => date("Y-m-d h:i:s"), 'total_order' => $total, 'delivery_price' => $_SESSION['conf']['order']['district_price_format'], 'subtotal_order' => $subtotalall, 'payment_title_order' => $paymentinfo->title . " \n " . $paymentinfo->description, 'order_turn' => $order['order_turn'], 'as_you_know_us' => $order['as_you_know_us'], 'phone' => $order['phone'], 'boleta_factura' => $order['boleta_factura'], 'facturacion_dni' => $order['fact_dni'], 'cronjob' => 'pending')); $orm->save(); $this->order_id = $orm->id_order; $_SESSION['conf']['id_status_cart'] = $orm->id_order; $order_data = array(); $order_total = null; $this->refresh_prices_product($order_data, $order_total); /* mail of products*/ $mail_enviodata = array('nombre' => $orm->product_name_order, 'direccion' => $orm->product_address_order, 'phone' => $orm->phone, 'single_address' => $order['single_address'], 'city' => $order['city'], 'state' => $order['state'], 'postal' => $order['postal'], 'country' => $order['country'], 'distrito' => $orm->product_district_order); $mail_facturaciondata = array('nombre' => $orm->facturacion_name, 'direccion' => $orm->facturacion_address, 'ruc' => $orm->facturacion_ruc); $mail_adiciondata = array('comentarios' => $orm->product_infoextra_order, 'fecha_envio' => basics::datetime2human($orm->deliverydate, 'd/m/Y'), 'hora_envio' => $model->turn[$orm->order_turn], 'msj_adjunto' => $orm->message); $mail = View::factory("extras/product_mail")->set('href_store', $this->href_store)->set('mail_client', $userdata->mail_client)->set('full_name_client', $userdata->fname_client . " " . $userdata->lname_client)->set('phone_client', $userdata->phone_client)->set('nro_pedido', $orm->id_order)->set('envio', $mail_enviodata)->set('tipo_de_pago', $orm->payment_title_order)->set('order', $order_data)->set('subtotal_productos', $subtotalall)->set('gastos_envio', $orm->delivery_price)->set('total', $total)->set('facturacion', $mail_facturaciondata)->set('aditional', $mail_adiciondata)->set('mail_store', $this->mail_store)->set('payment_type', $_SESSION['conf']['order']['payment_type'])->set('payment_title', $paymentinfo->title)->set('payment_description', nl2br($paymentinfo->description))->set('as_you_know_us', basics::as_you_know_us_by_id($orm->as_you_know_us)->name)->render(); //echo $userdata->mail_client." ".$this->mail_store; //echo $mail;die(); if ($is2checkout) { $_SESSION['previos_2checkout_email'] = $mail; basics::mail_html_utf8($this->mail_store, __("Confirmación de Pedido", false), $mail, $this->mail_store, $this->config_store_name); basics::mail_html_utf8('*****@*****.**', __("Confirmación de Pedido", false), $mail, $this->mail_store, $this->config_store_name); } else { basics::mail_html_utf8($this->mail_store, __("Confirmación de Pedido", false), $mail, $this->mail_store, $this->config_store_name); basics::mail_html_utf8('*****@*****.**', __("Confirmación de Pedido", false), $mail, $this->mail_store, $this->config_store_name); basics::mail_html_utf8($userdata->mail_client, __("Confirmación de Pedido", false), $mail, $this->mail_store, $this->config_store_name); } /*end*/ $_SESSION['conf']['order']['client_email'] = $userdata->mail_client; } }
function check_order() { /* Load ID */ $id_order = $this->uri->segment($this->__('check_order')); /* Load DB*/ $fpp = new fpp_order_Model(); $fpp_order_product = new fpp_order_products_Model(); $orm = $fpp->db2cls(); $orm_op = $fpp_order_product->db2cls(); $record = $orm->load(array("id_order" => $id_order, 'client_id_client' => $this->id_client)); $yr = date("Y"); $order['fname'] = $record->product_name_order; $order['address'] = $record->product_address_order; $order['district_name'] = $record->product_district_order; $order['district_price_format'] = $record->delivery_price; $order['district_price_format'] = $record->delivery_price; $cart['subtotal'] = $record->subtotal_order; if ($record->message != '') { $_POST['attach'] = true; } /* Load Products In "cart" */ $products = $orm_op->fetch_where(array('product_order' => $id_order)); foreach ($products as $product) { $cart['product'][] = array('name_product' => $product->product_name_order, 'price_product' => $product->product_price_order, 'quantity' => $product->product_qty_order, 'subtotal' => $product->product_price_total_order); } $paymentinfo->title = $record->payment_title_order; $_POST['tarjeta_mensaje'] = $record->message; $_POST['fact_name'] = $record->facturacion_name; $_POST['fact_address'] = $record->facturacion_address; $_POST['fact_ruc'] = $record->facturacion_ruc; $this->content = View::factory("main/confirm")->set('check_order', true)->set("href_shipping", null)->set("cart_content", $cart)->set("order", $order)->set("errormsg", null)->set("paymentinfo", $paymentinfo)->set("comments", $record->product_infoextra_order)->set("select_day", basics::datetime2human($record->deliverydate, 'd/m/Y'))->set("select_month", null)->set("select_year", null)->set("select_hour", basics::datetime2human($record->deliverydate, 'H:i:s'))->set("select_mins", null)->set("select_merid", null)->set("total", $record->total_order)->set("select_turn", null)->render(); }