* Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2015-2016 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Need to have following variables defined: * $object (invoice, order, ...) * $conf * $langs * $dateSelector * $forceall (0 by default, 1 for supplier invoices/orders) * $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) */ // Protection to avoid direct call of template if (empty($object) || ! is_object($object)) { print "Error, template page can't be called as URL"; exit; } $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) { $usemargins=1; } if (! isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine) global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax; if (! isset($dateSelector)) $dateSelector=1; // For backward compatibility elseif (empty($dateSelector)) $dateSelector=0; if (empty($forceall)) $forceall=0; if (empty($senderissupplier)) $senderissupplier=0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; // Define colspan for button Add $colspan = 3; // Col total ht + col edit + col delete if (in_array($object->element,array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button //print $object->element; // Lines for extrafield $objectline = null; if (!empty($extrafieldsline)) { if ($this->table_element_line=='commandedet') { $objectline = new OrderLine($this->db); } elseif ($this->table_element_line=='propaldet') { $objectline = new PropaleLigne($this->db); } elseif ($this->table_element_line=='supplier_proposaldet') { $objectline = new SupplierProposalLine($this->db); } elseif ($this->table_element_line=='facturedet') { $objectline = new FactureLigne($this->db); } elseif ($this->table_element_line=='contratdet') { $objectline = new ContratLigne($this->db); } elseif ($this->table_element_line=='commande_fournisseurdet') { $objectline = new CommandeFournisseurLigne($this->db); } elseif ($this->table_element_line=='facture_fourn_det') { $objectline = new SupplierInvoiceLine($this->db); } elseif ($this->table_element_line=='facturedet_rec') { $objectline = new FactureLigneRec($this->db); } } ?> lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { ?> global->MAIN_VIEW_LINE_NUMBER)) { ?>
trans('AddNewLine'); ?>trans("FreeZone"); ?> element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { ?> trans('SupplierRef'); ?> trans('VAT'); ?> trans('PriceUHT'); ?> multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan++;?> trans('PriceUHTCurrency'); ?> trans('PriceUTTC'); ?> trans('Qty'); ?> global->PRODUCT_USE_UNITS) { print ''; print ''; print $langs->trans('Unit'); print ''; } ?> trans('ReductionShort'); ?> situation_cycle_ref) { print '' . $langs->trans('Progress') . ''; } if (! empty($usemargins)) { if (!empty($user->rights->margins->creer)) { ?> global->MARGIN_TYPE == "1") echo $langs->trans('BuyingPrice'); else echo $langs->trans('CostPrice'); ?> rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''.$langs->trans('MarginRate').''; if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) echo ''.$langs->trans('MarkRate').''; } ?>   global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay=2; ?> global->MAIN_DISABLE_FREE_LINES)) { $freelines = true; $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) if ($object->element == 'contrat') { if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set else $forceall=0; } // Free line echo ''; // Show radio free line if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) { echo ''; echo ' '; } else { echo ''; // Show type selector if ($forceall >= 0) { if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type"); else echo $langs->trans("FreeLineOfType"); echo ' '; } } echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type",'alpha',2):-1,'type',1,1,$forceall); echo ''; } // Predefined product/service if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { if ($forceall >= 0 && $freelines) echo '
'; echo ''; echo ''; echo ' '; $filtertype=''; if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; if (empty($senderissupplier)) { if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); } else { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); } } else { // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum if ($senderissupplier != 2) { $ajaxoptions=array( 'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo) ); $alsoproductwithnosupplierprice=0; } else { $ajaxoptions = array(); $alsoproductwithnosupplierprice=1; } $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice); } echo ''; echo ''; } if (is_object($hookmanager) && empty($senderissupplier)) { $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int')); $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); if (!empty($hookmanager->resPrint)) { print $hookmanager->resPrint; } } if (is_object($hookmanager) && ! empty($senderissupplier)) { $parameters=array('htmlname'=>'addproduct'); $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action); if (!empty($hookmanager->resPrint)) { print $hookmanager->resPrint; } } if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { if (!empty($conf->variants->enabled)) { echo '
'; } echo '
'; } // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $nbrows=ROWS_2; $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; $toolbarname='dolibarr_details'; if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; $doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,$toolbarname,'',false,true,$enabled,$nbrows,'98%'); $doleditor->Create(); // Show autofill date for recuring invoices if (! empty($conf->service->enabled) && $object->element == 'facturerec') { echo '

'; echo $langs->trans('AutoFillDateFrom').' '; echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); echo ' - '; echo $langs->trans('AutoFillDateTo').' '; echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); echo '
'; } ?> element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { ?> "> tva_assuj == "0") echo ''.vatrate(0, true); else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx",'alpha',2):-1), $seller, $buyer, 0, 0, '', false, 1); ?> "> multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan++;?> "> "> "> global->PRODUCT_USE_UNITS) { print ''; print $form->selectUnits($line->fk_unit, "units"); print ''; } $remise_percent = $buyer->remise_percent; if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') { $remise_percent = $seller->remise_supplier_percent; } ?> ">% situation_cycle_ref) { $coldisplay++; print '%'; } if (! empty($usemargins)) { if (!empty($user->rights->margins->creer)) { ?> product->enabled) || ! empty($conf->service->enabled)) { ?> "> rights->margins->creer) { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { echo '%'; $coldisplay++; } if (! empty($conf->global->DISPLAY_MARK_RATES)) { echo '%'; $coldisplay++; } } else { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $coldisplay++; if (! empty($conf->global->DISPLAY_MARK_RATES)) $coldisplay++; } } ?> showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { $colspan = 6; if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { $colspan++; } if ($this->situation_cycle_ref) { $colspan++; } // We add 1 if col total ttc if (!empty($inputalsopricewithtax)) { $colspan++; } if ($conf->global->PRODUCT_USE_UNITS) { $colspan++; } if (count($object->lines)) { //There will be an edit and a delete button $colspan += 2; // With this, there is a column move button ONLY if lines > 1 if (in_array($object->element, array( 'propal', 'supplier_proposal', 'facture', 'facturerec', 'invoice', 'commande', 'order', 'order_supplier', 'invoice_supplier' ))) { $colspan++; } } if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; if (! empty($usemargins)) { if (!empty($user->rights->margins->creer)) $colspan++; // For the buying price if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; } ?> > global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> element) && $object->element == 'contrat') { print $langs->trans("DateStartPlanned").' '; $form->select_date($date_start,"date_start",$usehm,$usehm,1,"addproduct"); print '   '.$langs->trans("DateEndPlanned").' '; $form->select_date($date_end,"date_end",$usehm,$usehm,1,"addproduct"); } else { echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; echo $form->select_date($date_start,'date_start',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct",1,0,1); echo ' '.$langs->trans('to').' '; echo $form->select_date($date_end,'date_end',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct",1,0,1); }; print '' ?>