Exemplo n.º 1
0
 public function obAction()
 {
     $filter = array();
     if (isset($this->_params['status']) && !empty($this->_params['status'])) {
         $filter = array('status' => $this->_params['status']);
     }
     $type = $this->_params['type'];
     $filter += array('type' => $type);
     if (isset($this->_params['date_from']) && !empty($this->_params['date_from'])) {
         $filter += array('date_from' => convertUKtoUSdate($this->_params['date_from']));
     }
     if (isset($this->_params['date_to']) && !empty($this->_params['date_to'])) {
         $filter += array('date_to' => convertUKtoUSdate($this->_params['date_to']));
     }
     if (isset($this->_params['user']) && $this->_params['user'] == 'center') {
         $identity = (array) Zend_Auth::getInstance()->getIdentity();
         $filter += array('center_id' => $identity['id']);
     }
     /** @TODO paginator **/
     //        $limit = isset($this->_params['limit']) ?  $this->_params['limit'] : 30;
     //        $page_no =  isset($this->_params['page_no']) ?  $this->_params['page_no'] : 1;
     //
     //        $filter += array(
     //                     'limit'    => $limit,
     //                     'page_no'  => $page_no);
     // Exclude the ones that are from companies with checking
     // and have status like pending, rejected
     $identity = (array) Zend_Auth::getInstance()->getIdentity();
     if ($identity['role'] == 'center') {
         $_array = array();
         $__array = $this->getOrders()->getAll($filter)->toArray();
         // Verify if orders company is with check and has
         // status pending or rejected, then exclude tehm
         foreach ($__array as $a) {
             $_array[$a['id']] = $a;
             $company = $this->getCompanies()->getById($a['company_id']);
             if ($company->getWithCheck() == 1 && ($a['status'] == 'pending' || $a['status'] == 'rejected')) {
                 unset($_array[$a['id']]);
             }
         }
     } else {
         $_array = $this->getOrders()->getAll($filter)->toArray();
     }
     $join_in = array(array('customers', 'customer_id'), array('companies', 'company_id'), array('centers', 'center_id'), array('rates', 'rate_id'), array('users', 'created_user_id'), array('users', 'response_user_id'));
     $array = $this->_buildJoinTbl($_array, $join_in);
     $this->view->assign('array', $array);
     /** @TODO paginator **/
     //        $status = (isset($this->_params['status'])) ? $this->_params['status'] : '';
     //        $total_pages = $this->getOrders()->getTotal($status, $type);
     //        $this->view->assign('total_pages', $total_pages);
     //        $this->view->assign('limit', $limit);
     //        $this->view->assign('page_no', $page_no);
 }
Exemplo n.º 2
0
 public function testAction()
 {
     d(convertUKtoUSdate('03/05/2014'));
     d(convertUStoUKdate('2014-05-03'));
 }
Exemplo n.º 3
0
<?php

/**
 * Do the checkout process
 * save in 
 * cg_customers
 * cg_orders
 * cg_basket
 * @var mixed
 */
$delivery_date_text = mysqli_real_escape_string($conn, $_POST['delivery_date']);
$delivery_date = convertUKtoUSdate($delivery_date_text);
$birth_date_text = mysqli_real_escape_string($conn, $_POST['dob_date']);
$birth_date = convertUKtoUSdate($birth_date_text);
//    `amount_spend`
//    `amount_receive`
//    `currency_id`
//    `delivery_date`
//    `delivery_type`
//    `civility`
//    `first_name`
//    `last_name`
//    `email`
//    `phone`
//    `birth_date`
//    `zip`
//    `county`
//    `country`
//    `card_type`
//    `card_number`
//    `card_name`
Exemplo n.º 4
0
 public function obMultipleAction()
 {
     $identity = (array) Zend_Auth::getInstance()->getIdentity();
     $params = $this->getRequest()->getParams();
     $this->view->assign('type', $params['type']);
     $center = $this->getCenters()->getById($identity['center_id']);
     $center = !is_null($center) ? $center->toArray() : array();
     $company = $this->getCompanies()->getById($identity['company_id']);
     $company = !is_null($company) ? $company->toArray() : array();
     $toEmailCenter = $center['email'];
     $toEmailCompany = $company['email'];
     // Submited request
     if (isset($params['process_ob'])) {
         $uid = mt_rand(100000, 999999);
         $date_created = date('Y-m-d H:i:s');
         $date_delivery = isset($params['date_delivery']) ? $params['date_delivery'] : date('d/m/Y');
         $date_delivery = convertUKtoUSdate($date_delivery);
         $company_id = $identity['company_id'];
         $center_id = $identity['center_id'];
         $customer_id = $identity['customer_id'];
         $amount = null;
         $uk_amount = $params['total'];
         $created_user_id = $identity['id'];
         $payment_type = $params['payment_type'];
         $traveller_name = $params['traveller_name'];
         $comment = $params['comment'];
         $type = $params['type'];
         $is_multiple = 1;
         $status = $company['with_check'] ? Table_Abstract::STATUS_PENDING : Table_Abstract::STATUS_UNPROCESSED;
         $ob = $this->getOrders()->createRow();
         $ob_id = $ob->setUid($uid)->setDateCreated($date_created)->setDateDelivery($date_delivery)->setCompanyId($company_id)->setCenterId($center_id)->setCustomerId($customer_id)->setAmount($amount)->setUkAmount($uk_amount)->setCreatedUserId($created_user_id)->setPaymentType($payment_type)->setTravellerName($traveller_name)->setComment($comment)->setType($type)->setIsMultiple($is_multiple)->setStatus($status)->save();
         // add to ob multiple
         foreach ($params['rate_id'] as $k => $rate_id) {
             $rate = $params['rate'][$k];
             $amount = $params['amount'][$k];
             $uk_amount = $params['uk_amount'][$k];
             $ob_multiple = $this->getObMultiple()->createRow();
             $ob_multiple->setObId($ob_id)->setRateId($rate_id)->setRate($rate)->setPaymentType($payment_type)->setAmount($amount)->setUkAmount($uk_amount)->save();
         }
         /**
          * Get order by uid
          * @var mixed
          */
         $ob = $this->getOrders()->getByUid($uid);
         $join_in = array(array('customers', 'customer_id'), array('companies', 'company_id'), array('centers', 'center_id'), array('rates', 'rate_id'), array('users', 'created_user_id'), array('users', 'response_user_id'));
         $ob = $this->_buildJoinTbl(array($ob), $join_in);
         $ob = $ob[0];
         $ob['company'] = $company;
         // Ob multiple
         $ob_multiple = array();
         $_ob_multiple = $this->getObMultiple()->geByOrderId($ob['id'])->toArray();
         foreach ($_ob_multiple as $obm) {
             $ob_multiple[$obm['id']] = $obm;
             $ob_multiple[$obm['id']]['rate_detail'] = $this->getRates()->getById($obm['rate_id'])->toArray();
         }
         $ob['multiple'] = $ob_multiple;
         /**
          * Send mail to processing center with order
          * @var NL_HtmlMailer
          */
         $is_error = false;
         $email = new NL_HtmlMailer();
         $email->sendOb($ob, $toEmailCenter);
         /** @var Send mail to approvers $approversTable */
         $approversTable = new Table_Approvers();
         $approvers = $approversTable->getByCompanyId($company['id']);
         foreach ($approvers->toArray() as $approver) {
             if (!is_null($approver['email']) && !empty($approver['email'])) {
                 $email->sendOb($ob, $approver['email']);
             }
         }
         /** send to company if with approve */
         if ($company['with_check']) {
             $email->sendOb($ob, $toEmailCompany);
         }
         // MESSAGE
         if (!$is_error) {
             // Success promotional message
             include APPLICATION_PATH . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'AjaxObController.php';
             $out = AjaxObController::renderSuccessMessage($type, $uid, $payment_type, $is_multiple = true);
         } else {
             // error message
             $out = NL_Render::renderErrorMessage();
         }
         echo $out;
         $this->view->assign('show_view', false);
     } else {
         $this->view->assign('show_view', true);
     }
 }
Exemplo n.º 5
0
 /**
  * The final step in which we save the order
  * and send email to processing center to deal with it
  */
 public function obStep3Action()
 {
     $out = '';
     $params = $this->getRequest()->getParams();
     // Set params
     $identity = (array) Zend_Auth::getInstance()->getIdentity();
     $created_user_id = $identity['id'];
     $type = $params['type'];
     $payment_type = $params['payment_type'];
     $rate_id = $params['rate_id'];
     $amount = $params['amount'];
     $uk_amount = $params['uk_amount'];
     $traveller_name = $params['traveller_name'];
     $comment = $params['comment'];
     $uid = mt_rand(100000, 999999);
     $date_created = date('Y-m-d H:i:s');
     $date_delivery = isset($params['date_delivery']) ? $params['date_delivery'] : date('d/m/Y');
     // format date_delivery
     $date_delivery = convertUKtoUSdate($date_delivery);
     $user = $this->getUsers()->getById($created_user_id);
     $user = !is_null($user) ? $user->toArray() : array();
     if (!empty($user)) {
         $company = $this->getCompanies()->getById($user['company_id']);
         $company = !is_null($company) ? $company->toArray() : array();
     }
     $ordersTable = new Table_Orders();
     $o = $ordersTable->createRow();
     // Save in db
     $o->setUid($uid)->setDateCreated($date_created)->setDateDelivery($date_delivery)->setAmount($amount)->setUkAmount($uk_amount)->setRateId($rate_id)->setCreatedUserId($created_user_id)->setPaymentType($payment_type)->setTravellerName($traveller_name)->setComment($comment)->setCompanyId($user['company_id'])->setCenterId($user['center_id'])->setCustomerId($user['customer_id'])->setType($type);
     if ($company['with_check'] == 1) {
         $o->setStatus(Table_Abstract::STATUS_PENDING);
     }
     // Get email in which to send
     $identity = (array) Zend_Auth::getInstance()->getIdentity();
     $center = $this->getCenters()->getById($identity['center_id']);
     $center = !is_null($center) ? $center->toArray() : array();
     $toEmailCenter = $center['email'];
     $toEmailCompany = $company['email'];
     // If saves the order in db
     $is_error = false;
     if ($o->save()) {
         $user = (array) Zend_Auth::getInstance()->getIdentity();
         $company = $this->getCompanies()->getById($user['company_id']);
         $company = !is_null($company) ? $company->toArray() : array();
         /**
          * Get order by uid
          * @var mixed
          */
         $ob = $this->getOrders()->getByUid($uid);
         $join_in = array(array('customers', 'customer_id'), array('companies', 'company_id'), array('centers', 'center_id'), array('rates', 'rate_id'), array('users', 'created_user_id'), array('users', 'response_user_id'));
         $ob = $this->_buildJoinTbl(array($ob), $join_in);
         $ob = $ob[0];
         $ob['margins'] = $this->getMargins()->getFeeByRateCode($ob['rate']['c_code']);
         $ob['company'] = $company;
         /**
          * Send mail to processing center with order
          * @var NL_HtmlMailer
          */
         $is_error = false;
         $email = new NL_HtmlMailer();
         $email->sendOb($ob, $toEmailCenter);
         /** send to company if with approve */
         if ($company['with_check']) {
             $email->sendOb($ob, $toEmailCompany);
         }
         /** @var Send mail to approvers $approversTable */
         $approversTable = new Table_Approvers();
         $approvers = $approversTable->getByCompanyId($company['id']);
         foreach ($approvers->toArray() as $approver) {
             if (!is_null($approver['email']) && !empty($approver['email'])) {
                 $email->sendOb($ob, $approver['email']);
             }
         }
     } else {
         $is_error = true;
     }
     // MESSAGE
     if (!$is_error) {
         // Success promotional message
         $out = self::renderSuccessMessage($type, $uid, $params['payment_type'], $is_multiple = false);
     } else {
         // error message
         $out = NL_Render::renderErrorMessage();
     }
     echo $out;
 }
Exemplo n.º 6
0
 /**
  * Set table parameters accordingly
  *  
  * @param mixed $a
  * @param mixed $params
  */
 protected function _setSwitchTables($a = array(), $params = array())
 {
     switch ($params['table']) {
         // COMPANIES
         case 'companies':
             $params['first_time'] = isset($params['first_time']) ? $params['first_time'] : 0;
             $params['first_time'] = isset($params['user_mod']) ? 1 : $params['first_time'];
             $params['with_check'] = isset($params['with_check']) ? $params['with_check'] : 0;
             if (isset($params['email']) && !empty($params['email'])) {
                 $a->setEmail($params['email']);
             }
             if (isset($params['password']) && !empty($params['password'])) {
                 $params['password'] = Table_Abstract::encryptPassword($params['password']);
                 $a->setPassword($params['password']);
             }
             $a->setWithCheck($params['with_check'])->setFirstTime($params['first_time'])->setName($params["name"])->setImgId($params["img_id"])->setCashSFlatFee($params["cash_s_flat_fee"])->setCashSPercentageFee($params["cash_s_percentage_fee"])->setCashSMinimumFee($params["cash_s_minimum_fee"])->setCashSFeeType($params["cash_s_fee_type"])->setCashBFlatFee($params["cash_b_flat_fee"])->setCashBPercentageFee($params["cash_b_percentage_fee"])->setCashBMinimumFee($params["cash_b_minimum_fee"])->setCashBFeeType($params["cash_b_fee_type"])->setTcSFlatFee($params["tc_s_flat_fee"])->setTcSPercentageFee($params["tc_s_percentage_fee"])->setTcSMinimumFee($params["tc_s_minimum_fee"])->setTcSFeeType($params["tc_s_fee_type"])->setTcBFlatFee($params["tc_b_flat_fee"])->setTcBPercentageFee($params["tc_b_percentage_fee"])->setTcBMinimumFee($params["tc_b_minimum_fee"])->setTcBFeeType($params["tc_b_fee_type"])->setChequeSFlatFee($params["cheque_s_flat_fee"])->setChequeSPercentageFee($params["cheque_s_percentage_fee"])->setChequeSMinimumFee($params["cheque_s_minimum_fee"])->setChequeSFeeType($params["cheque_s_fee_type"])->setChequeBFlatFee($params["cheque_b_flat_fee"])->setChequeBPercentageFee($params["cheque_b_percentage_fee"])->setChequeBMinimumFee($params["cheque_b_minimum_fee"])->setChequeBFeeType($params["cheque_b_fee_type"]);
             break;
             // CUSTOMERS
         // CUSTOMERS
         case 'customers':
             $a->setName($params['name']);
             break;
             // Payments
         // Payments
         case 'payments':
             $a->setName($params['name']);
             break;
             // CENTERS
         // CENTERS
         case 'centers':
             $params['first_time'] = isset($params['first_time']) ? $params['first_time'] : 0;
             $params['first_time'] = isset($params['user_mod']) ? 1 : $params['first_time'];
             $a->setName($params['name'])->setHexColor($params['hex_color'])->setContact($params['contact'])->setFirstTime($params['first_time']);
             if (isset($params['email']) && !empty($params['email'])) {
                 $a->setEmail($params['email']);
             }
             if (isset($params['password']) && !empty($params['password'])) {
                 $params['password'] = Table_Abstract::encryptPassword($params['password']);
                 $a->setPassword($params['password']);
             }
             break;
             // MARGINS
         // MARGINS
         case 'margins':
             $a->setRateCCode($params['rate_c_code'])->setCashFeeB($params['cash_fee_b'])->setCashFeeS($params['cash_fee_s'])->setTcFeeB($params['tc_fee_b'])->setTcFeeS($params['tc_fee_s'])->setChequeFeeB($params['cheque_fee_b']);
             //                    ->setChequeFeeS($params['cheque_fee_s']);
             break;
             // RATES
         // RATES
         case 'rates':
             $params['c_unit'] = empty($params['c_unit']) || is_null($params['c_unit']) ? 1 : $params['c_unit'];
             $a->setCountry($params['country'])->setCUnit($params['c_unit'])->setCCode($params['c_code'])->setCSymbol($params['c_symbol'])->setBRate($params['b_rate'])->setBNote($params['b_note'])->setSRate($params['s_rate'])->setSNote($params['s_note'])->setDateUpdate($params['date_update']);
             break;
             // USERS
         // USERS
         case 'users':
             $params['approval_limit'] = empty($params['approval_limit']) || is_null($params['approval_limit']) ? 1 : $params['approval_limit'];
             $params['first_time'] = isset($params['user_mod']) ? 1 : $params['first_time'];
             if (!isset($params['user_mod'])) {
                 $a->setApprovalLimit($params['approval_limit'])->setRole($params['role'])->setCustomerId($params['customer_id'])->setCompanyId($params['company_id'])->setCenterId($params['center_id']);
             }
             if (isset($params['username']) && !empty($params['username'])) {
                 $a->setUsername($params['username']);
             }
             if (isset($params['password']) && !empty($params['password'])) {
                 $params['password'] = Table_Abstract::encryptPassword($params['password']);
                 $a->setPassword($params['password']);
             }
             $a->setFullName($params['full_name'])->setPhone($params['phone'])->setFax($params['fax'])->setMobile($params['mobile'])->setEmail($params['email'])->setFirstTime($params['first_time']);
             break;
             // APPROVERS
         // APPROVERS
         case 'approvers':
             $params['approval_limit'] = empty($params['approval_limit']) || is_null($params['approval_limit']) ? 1 : $params['approval_limit'];
             $params['first_time'] = isset($params['user_mod']) ? 1 : $params['first_time'];
             if (!isset($params['user_mod'])) {
                 $a->setApprovalLimit($params['approval_limit'])->setCustomerId($params['customer_id'])->setCompanyId($params['company_id']);
             }
             if (isset($params['username']) && !empty($params['username'])) {
                 $a->setUsername($params['username']);
             }
             if (isset($params['password']) && !empty($params['password'])) {
                 $params['password'] = Table_Abstract::encryptPassword($params['password']);
                 $a->setPassword($params['password']);
             }
             $a->setFullName($params['full_name'])->setPhone($params['phone'])->setFax($params['fax'])->setMobile($params['mobile'])->setEmail($params['email'])->setFirstTime($params['first_time']);
             break;
             // ORDERS
         // ORDERS
         case 'orders':
             //                dd($params);
             $params['date_created'] = empty($params['date_created']) || is_null($params['date_created']) ? date('Y-m-d') : convertUKtoUSdate($params['date_created']);
             $params['date_delivery'] = empty($params['date_delivery']) || is_null($params['date_delivery']) ? date('Y-m-d') : convertUKtoUSdate($params['date_delivery']);
             if (isset($params['status']) && !empty($params['status'])) {
                 $a->setStatus($params['status']);
             }
             if (isset($params['date_created'])) {
                 $a->setDateCreated($params['date_created']);
             }
             if (isset($params['date_response'])) {
                 $a->setDateResponse(convertUKtoUSdate($params['date_response']));
             }
             if (isset($params['date_delivery'])) {
                 $a->setDateDelivery($params['date_delivery']);
             }
             if (isset($params['company_id'])) {
                 $a->setCompanyId($params['company_id']);
             }
             if (isset($params['center_id'])) {
                 $a->setCenterId($params['center_id']);
             }
             if (isset($params['customer_id'])) {
                 $a->setCustomerId($params['customer_id']);
             }
             if (isset($params['amount'])) {
                 $a->setAmount($params['amount']);
             }
             if (isset($params['uk_amount'])) {
                 $a->setUkAmount($params['uk_amount']);
             }
             if (isset($params['rate_id'])) {
                 $a->setRateId($params['rate_id']);
             }
             if (isset($params['created_user_id'])) {
                 $a->setCreatedUserId($params['created_user_id']);
             }
             if (isset($params['response_user_id'])) {
                 $a->setResponseUserId($params['response_user_id']);
             }
             if (isset($params['type'])) {
                 $a->setType($params['type']);
             }
             if (isset($params['payment_type'])) {
                 $a->setPaymentType($params['payment_type']);
             }
             if (isset($params['traveller_name'])) {
                 $a->setTravellerName($params['traveller_name']);
             }
             if (isset($params['comment'])) {
                 $a->setComment($params['comment']);
             }
             if (isset($params['uid'])) {
                 $a->setUid($params['uid']);
             }
             break;
     }
     return $a;
 }