} if ($search_status == '') { $search_status = -1; } // List of fields to search into when doing a "search in all" $fieldstosearchall = array('cf.ref' => 'Ref', 'cf.ref_supplier' => 'RefSupplier', 's.nom' => "ThirdParty", 'cf.note_public' => 'NotePublic'); if (empty($user->socid)) { $fieldstosearchall["cf.note_private"] = "NotePrivate"; } /* * View */ $thirdpartytmp = new Fournisseur($db); $commandestatic = new CommandeFournisseur($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $title = $langs->trans("SuppliersOrders"); if ($socid > 0) { $fourn = new Fournisseur($db); $fourn->fetch($socid); $title .= ' - ' . $fourn->name; } if ($status) { if ($status == '1,2,3') { $title .= ' - ' . $langs->trans("StatusOrderToProcessShort"); } if ($status == '6,7') { $title .= ' - ' . $langs->trans("StatusOrderCanceled"); } else { $title .= ' - ' . $langs->trans($commandestatic->statuts[$status]); }
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); exit; } else { dol_print_error($db); } } } } } /* * View */ llxHeader('', $langs->trans("OrderCard"), "CommandeFournisseur"); $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $productstatic = new Product($db); /* *************************************************************************** */ /* */ /* Mode vue et edition */ /* */ /* *************************************************************************** */ $now = dol_now(); if ($action == "create") { print_fiche_titre($langs->trans('NewOrder')); dol_htmloutput_mesg($mesg); dol_htmloutput_events(); $societe = ''; if ($socid > 0) { $societe = new Societe($db); $societe->fetch($socid);
if ($search_status == '') { $search_status = -1; } /* * View */ $title = $langs->trans("SuppliersOrders"); if ($socid > 0) { $fourn = new Fournisseur($db); $fourn->fetch($socid); $title .= ' (' . $fourn->name . ')'; } llxHeader('', $title); $commandestatic = new CommandeFournisseur($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); if ($sortorder == "") { $sortorder = "DESC"; } if ($sortfield == "") { $sortfield = "cf.date_creation"; } $offset = $conf->liste_limit * $page; /* * Mode Liste */ $sql = "SELECT s.rowid as socid, s.nom as name, cf.date_commande as dc,"; $sql .= " cf.rowid,cf.ref, cf.ref_supplier, cf.fk_statut, cf.total_ttc, cf.fk_user_author,cf.date_livraison,"; $sql .= " u.login"; $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s,"; $sql .= " " . MAIN_DB_PREFIX . "commande_fournisseur as cf";
$mesg = '<div class="error">' . $langs->trans('ErrorCantReadFile', $file) . '</div>'; dol_syslog('Failed to read file: ' . $file); } } else { $langs->load("other"); $mesg = '<div class="error">' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Invoice")) . '</div>'; dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.'); } } /* * View */ llxHeader('', $langs->trans("OrderCard"), "CommandeFournisseur"); $html = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $productstatic = new Product($db); /* *************************************************************************** */ /* */ /* Mode vue et edition */ /* */ /* *************************************************************************** */ $now = dol_now(); if ($id > 0 || !empty($ref)) { //if ($mesg) print $mesg.'<br>'; $result = $object->fetch($id, $ref); if ($result >= 0) { $soc = new Societe($db); $soc->fetch($object->socid); $author = new User($db); $author->fetch($object->user_author_id);
echo ajax_constantonoff('GRAPEFRUIT_FORCE_VAR_HIDEREF_ON_SUPPLIER_ORDER'); print '</td></tr>'; if (!empty($conf->fournisseur->enabled) && !empty($conf->commande->enabled) && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>' . $langs->trans("set_GRAPEFRUIT_SUPPLIER_ORDER_CLASSIFY_RECEIPT_ORDER") . '</td>'; print '<td align="center" width="20"> </td>'; print '<td align="right" width="300">'; print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="set_GRAPEFRUIT_SUPPLIER_ORDER_CLASSIFY_RECEIPT_ORDER">'; echo ajax_constantonoff('GRAPEFRUIT_SUPPLIER_ORDER_CLASSIFY_RECEIPT_ORDER'); print '</form>'; print '</td></tr>'; } $formorder = new FormOrder($db); $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>' . $langs->trans("set_GRAPEFRUIT_AUTO_ORDER_ON_SUPPLIERORDER_VALIDATION_WITH_METHOD") . '</td>'; print '<td align="center" width="20"> </td>'; print '<td align="right" width="300">'; print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />'; print '<input type="hidden" name="action" value="set_GRAPEFRUIT_AUTO_ORDER_ON_SUPPLIERORDER_VALIDATION_WITH_METHOD" />'; $formorder->selectInputMethod($conf->global->GRAPEFRUIT_AUTO_ORDER_ON_SUPPLIERORDER_VALIDATION_WITH_METHOD, "GRAPEFRUIT_AUTO_ORDER_ON_SUPPLIERORDER_VALIDATION_WITH_METHOD", 1); print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">'; print '</form>'; print '</td></tr>'; print '<tr class="liste_titre">'; print '<td>' . $langs->trans("CustomerOrder") . '</td>' . "\n"; print '<td align="center" width="20"> </td>';
public function orderAction() { $this->view->headLink()->prependStylesheet($this->view->LocateFile('cart.css')); $session = new Zend_Session_Namespace('order'); $urlBack = ''; $urlNextStep = ''; $urls = Cible_View_Helper_LastVisited::getLastVisited(); $profile = new MemberProfile(); $oAddress = new AddressObject(); $authentication = Cible_FunctionsGeneral::getAuthentication(); $memberInfos = $profile->findMember(array('email' => $authentication['email'])); $page = Cible_FunctionsCategories::getPagePerCategoryView(0, 'list_collections', 14); // If authentication is not present or if cart is empty, redirect to the cart page if (!is_null($authentication)) { // $memberInfos = $profile->addTaxRate($memberInfos); if (!empty($memberInfos['addrBill'])) { $billAddr = $oAddress->populate($memberInfos['addrBill'], $this->_defaultInterfaceLanguage); } if (!empty($memberInfos['addrShip'])) { $shipAddr = $oAddress->populate($memberInfos['addrShip'], $this->_defaultInterfaceLanguage); } // $oRetailer = new RetailersObject(); // $memberInfos['AI_FirstTel'] = $billAddr['AI_FirstTel']; // $memberInfos['AI_SecondTel'] = $billAddr['AI_SecondTel']; // $memberInfos['A_Fax'] = $billAddr['A_Fax']; if (isset($billAddr['AI_WebSite'])) { $memberInfos['AI_WebSite'] = $billAddr['AI_WebSite']; } $memberInfos['addressFact'] = $billAddr; if (isset($shipAddr['A_Duplicate']) && !$shipAddr['A_Duplicate']) { $shipAddr['duplicate'] = 0; } $memberInfos['addressShipping'] = $shipAddr; $current_state = $billAddr['A_StateId'] . '||' . $shipAddr['A_StateId'] . '||'; $currentCity = $billAddr['A_CityId'] . '||' . $shipAddr['A_CityId'] . '||'; // $onWeb = $oRetailer->getRetailerInfos($memberInfos['member_id'], $this->_defaultInterfaceLanguage); // if ($onWeb && !empty($onWeb['R_AddressId'])) // { // $webAddr = $oAddress->populate($onWeb['R_AddressId'], $this->_defaultInterfaceLanguage); // // $webAddr['isDistributeur'] = $onWeb['R_Status']; // $memberInfos['addressDetaillant'] = $webAddr; // // $current_state .= $webAddr['A_StateId'] . '||'; // $currentCity .= $webAddr['A_CityId'] . '||'; // } $return = $this->_getParam('return'); if ($return && isset($_COOKIE['returnUrl'])) { $returnUrl = $_COOKIE['returnUrl']; $this->view->assign('return', $returnUrl); } $pageOrderName = Cible_FunctionsCategories::getPagePerCategoryView(0, 'order', $this->_moduleID); $tmp = explode('/', $pageOrderName); $tmp = array_unique($tmp); $pageOrderName = $tmp[0]; $stepValues = array('auth-order' => array('step' => 2, 'next' => $pageOrderName . '/resume-order', 'prev' => ''), 'resume-order' => array('step' => 3, 'next' => $pageOrderName . '/send-order', 'prev' => 'auth-order'), 'send-order' => array('step' => 4, 'next' => '', 'prev' => 'resume-order')); $stepAction = $this->_getParam('action'); $urlBack = $stepValues[$stepAction]['prev']; if (empty($stepValues[$stepAction]['prev']) && isset($urls[0])) { $urlBack = $urls[0]; } $this->view->assign('step', $stepValues[$stepAction]['step']); $this->view->assign('nextStep', $stepValues[$stepAction]['next']); $this->view->assign('urlBack', $urlBack); $orderParams = Cible_FunctionsGeneral::getParameters(); switch ($stepAction) { case 'resume-order': if (empty($session->customer)) { $this->_redirect(Cible_FunctionsPages::getPageNameByID(1)); } // Create this form to fill with values used for the read-only rendering $formOrder = new FormOrder(array('resume' => true)); // Store the state id in the session to allow tax calculation $session->stateId = $billAddr['A_StateId']; // Calculate totals to display and for the bill. $totals = $this->calculateTotal($memberInfos); $session->order['charge_total'] = $totals['total']; $session->order['subTotal'] = $totals['subTot']; $session->order['taxFed'] = $totals['taxFed']; $session->order['taxProv'] = $totals['taxProv']; $session->order['nbPoint'] = $totals['nbPoint']; $session->order['shipFee'] = $orderParams['CP_ShippingFees']; $session->order['limitShip'] = $orderParams['CP_ShippingFeesLimit']; $session->order['CODFees'] = $orderParams['CP_MontantFraisCOD']; $session->order['rateFed'] = 0; if ($session->stateId == 11) { $session->order['rateFed'] = $orderParams['CP_TauxTaxeFed']; } if (isset($session->customer['addressShipping']['duplicate']) && $session->customer['addressShipping']['duplicate']) { unset($session->customer['addressShipping']); $session->customer['addressShipping'] = $session->customer['addressFact']; } $dataBill = $this->getAddrData($session->customer['addressFact'], 'addressFact', $session); $dataShip = $this->getAddrData($session->customer['addressShipping'], 'addressShipping', $session); $salut = Cible_FunctionsGeneral::getSalutations($memberInfos['salutation'], Zend_Registry::get('languageID')); if (isset($salut[$memberInfos['salutation']])) { $session->customer['identification']['salutation'] = utf8_decode($salut[$memberInfos['salutation']]); } else { $session->customer['identification']['salutation'] = "-"; } $formOrder->populate($session->customer); $formOrder->getSubForm('addressShipping')->removeElement('duplicate'); $formOrder->getSubForm('identification')->removeElement('password'); $formOrder->getSubForm('identification')->removeElement('passwordConfirmation'); $formOrder->getSubForm('identification')->removeElement('noFedTax'); $formOrder->getSubForm('identification')->removeElement('noProvTax'); $formOrder->getSubForm('identification')->removeElement('AI_FirstTel'); $formOrder->getSubForm('identification')->removeElement('AI_SecondTel'); $formOrder->getSubForm('identification')->removeElement('AI_WebSite'); $formOrder->getSubForm('identification')->removeElement('A_Fax'); $readOnly = new Cible_View_Helper_FormReadOnly(); $readOnly->setAddSeparator(true); $readOnly->setSeparatorClass('dotLine'); $readOnly->setListOpened(false); $readOnly->setSeparatorPositon(array(1)); $readOnlyForm = $readOnly->subFormRender($formOrder); $formPayment = new FormOrderPayment(array('readOnlyForm' => $readOnlyForm, 'payMean' => $session->customer['paymentMeans'])); // $formPayment->populate($session->order); if ($this->_request->isPost() && array_key_exists('submit', $_POST)) { $formData = $this->_request->getPost(); $session->customer['invoice'] = $formData; // $session->customer['indentification'] = $memberInfos; $this->_redirect($stepValues[$stepAction]['next']); } $session->customer['charge_total'] = sprintf('%.2f', $totals['total']); $formPayment->populate($session->customer); $this->view->assign('CODFees', $orderParams['CP_MontantFraisCOD']); $this->view->assign('memberInfos', $memberInfos); $this->view->assign('formOrder', $formPayment); $this->renderScript('index/order-summary.phtml'); break; case 'send-order': if ($this->_request->isPost()) { // if ($this->_request->getParam('response_code') > 50) if ($this->_request->getParam('response_code') < 50 && $this->_request->getParam('response_code') != 'null') { $session->order['confirmation'] = $_POST; } else { $this->view->assign('errorValidation', $this->view->getClientText('card_payment_error_message')); $session->customer['message'] = $this->view->getClientText('card_payment_error_message'); $this->_redirect($pageOrderName . '/' . $stepValues['resume-order']['prev'] . '/errorValidation/1'); } } $this->sendOrder(); $urlBack = $this->view->BaseUrl() . '/' . $page; $this->view->assign('backHomeLink', $urlBack); $this->renderScript('index/order-sent.phtml'); break; default: // $oCart = new Cart(); // $cartHeader = $oCart->getCartData(); // $cartId = $oCart->getId(); // $files = $oCart->manageFileUpload(); $form = new FormOrderAddr(array('hasAccount' => $memberInfos['hasAccount'])); // $this->getAddrData($memberInfos['addressFact'], 'addressFact', $session); // $address = array_merge($memberInfos['addressFact'], $session->customer['addressFact']); // $form->getSubForm('addressFact')->populate($address); // // $readOnly = new Cible_View_Helper_FormReadOnly(); // $readOnly->setAddSeparator(true); // $readOnly->setSeparatorClass('dotLine'); // $readOnly->setListOpened(true); // $readOnly->setSeparatorPosition(array(1)); // $readOnlyForm = $readOnly->subFormRender($form, 'addressFact'); // // $newForm = new FormOrderAddr(array('readOnlyBillAddr' => $readOnlyForm)); if ($this->_request->isPost()) { $statePost = ''; $cityPost = ''; $data = $this->_request->getPost(); $currentCity = 0; $current_state = $data['addressFact']['A_StateId'] . '||'; $current_state .= $data['addressShipping']['A_StateId']; // $currentCity = (empty($cityPost)) ? substr($currentCity, 0, -1) : substr($cityPost, 0, -1); // $current_state = (empty($statePost)) ? substr($current_state, 0, -1) : substr($statePost, 0, -1); $memberInfos['selectedState'] = $session->customer['selectedState']; $memberInfos['selectedCity'] = $session->customer['selectedCity']; } if ($this->_request->isPost() && array_key_exists('submit', $_POST)) { $formData = $this->_request->getPost(); $formData['selectedState'] = $current_state; $formData['selectedCity'] = $currentCity; //Remove data validation if not a new address $addrSource = $newForm->getSubForm('addressShipping')->getElement('addrSource')->getValue(); if ($addrSource == 1 || $addrSource == 3) { $subFormShip = $form->getSubForm('addressShipping'); foreach ($subFormShip as $key => $value) { $value->clearValidators()->setRequired(false); } } // if ($formData['paymentMeans'] == 'compte' && !$memberInfos['hasAccount']) // { // $newForm->getElement('paymentMeans')->setErrors(array($this->view->getClientText('no_customer_account'))); // $formData['paymentMeans'] = null; // } if ($form->isValid($formData)) { // if($formData['paymentMeans'] == 'cod') // $session->order['cod'] = $formData['paymentMeans']; // elseif(isset($session->order['cod'])) // unset($session->order['cod']); $session->customer = $formData; $session->customer['identification'] = $memberInfos; $this->_redirect($stepValues[$stepAction]['next']); } else { $form->populate($formData); } } else { $memberInfos['selectedState'] = $current_state; $memberInfos['selectedCity'] = $currentCity; $form->populate($memberInfos); } $this->view->assign('CODFees', $orderParams['CP_MontantFraisCOD']); $this->view->assign('form', $form); $this->view->assign('memberInfos', $memberInfos); $this->view->assign('accountValidate', $memberInfos['validatedEmail']); break; } } else { $this->_redirect(Cible_FunctionsPages::getPageNameByID(1)); } }