diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 5265f73e595..f1bf108f14c 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -87,6 +87,11 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { $listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder'); } +// Search supplier proposal +if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) +{ + $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort'); +} // Search supplier order if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { @@ -100,12 +105,7 @@ if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) // Search contract if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - $listofsearchfields['search_contract']=array('text'=>'Contrat'); -} -// Search supplier proposal -if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) -{ - $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort'); + $listofsearchfields['search_contract']=array('text'=>'Contract'); } if (count($listofsearchfields)) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 0acd58f0202..b18c5bf7b48 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -341,6 +341,17 @@ class FactureRec extends CommonInvoice } + /** + * Create an array of invoice lines + * + * @return int >0 if OK, <0 if KO + */ + function getLinesArray() + { + return $this->fetch_lines(); + } + + /** * Recupere les lignes de factures predefinies dans this->lines * @@ -348,16 +359,23 @@ class FactureRec extends CommonInvoice */ function fetch_lines() { + $this->lines=array(); + $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; $sql.= ' l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.total_ht, l.total_tva, l.total_ttc,'; + $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + //$sql.= ' l.situation_percent, l.fk_prev_id,'; + //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; + //$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' l.fk_unit, l.fk_contract_line,'; + //$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; - + $sql.= ' ORDER BY l.rang'; + dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); if ($result) @@ -387,10 +405,6 @@ class FactureRec extends CommonInvoice $line->remise_percent = $objp->remise_percent; $line->fk_remise_except = $objp->fk_remise_except; $line->fk_product = $objp->fk_product; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; $line->info_bits = $objp->info_bits; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; @@ -415,7 +429,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->error(); + $this->error=$this->db-lasterror(); return -3; } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index ad9626718c6..2e595d45daf 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -73,6 +73,13 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') } } +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('invoicecard','globalcard')); + +$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php + /* * Actions @@ -101,7 +108,7 @@ if ($action == 'add') $rehour=GETPOST('rehour'); $remin=GETPOST('remin'); $nb_gen_max=GETPOST('nb_gen_max', 'int'); - if (empty($nb_gen_max)) $nb_gen_max =0; + //if (empty($nb_gen_max)) $nb_gen_max =0; if (GETPOST('frequency')) { @@ -111,7 +118,7 @@ if ($action == 'add') $action = "create"; $error++; } - if ($nb_gen_max == '') + if ($nb_gen_max === '') { setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors'); $action = "create"; @@ -599,7 +606,9 @@ if ($action == 'create') if ($object->fetch($id, $ref) > 0) { - print '
'; + $result = $object->getLinesArray(); + + print ''; print ''; print ''; print ''; @@ -707,10 +716,22 @@ if ($action == 'create') print load_fiche_titre($title, '', ''); - /* * Invoice lines */ + print ''; + // Show object lines + if (! empty($object->lines)) + { + $disableedit=1; + $disablemove=1; + $disableremove=1; + $ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice + } + + print "
\n"; + + /* print ''; print '
'; @@ -877,7 +898,8 @@ if ($action == 'create') print $db->error(); } print "
"; - + */ + print ''; if ($flag_price_may_change) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ec02fce3dae..349ff1e20b1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3236,8 +3236,9 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $langs, $user; - + global $conf, $hookmanager, $langs, $user; + global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! + // Define usemargins $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1; @@ -3366,7 +3367,7 @@ abstract class CommonObject { global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd; - global $object_rights, $disableedit, $disablemove; // TODO We should not use global var for this ! + global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! $object_rights = $this->getRights(); diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 967d9f81970..559cae91464 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -31,7 +31,7 @@ * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $usemargins (0 to disable all margins columns, 1 to show according to margin setup) * $object_rights->creer initialized from = $object->getRights() - * $disableedit, $disablemove + * $disableedit, $disablemove, $disableremove * * $type, $text, $description, $line */ @@ -46,7 +46,6 @@ if (empty($forceall)) $forceall=0; if (empty($senderissupplier)) $senderissupplier=0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; if (empty($usemargins)) $usemargins=0; - ?> @@ -216,7 +215,7 @@ if (empty($usemargins)) $usemargins=0; situation_counter == 1 || !$this->situation_cycle_ref) { + if (($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disableremove)) { print 'id . '">'; print img_delete(); print ''; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 4547a94566a..c52c72ff509 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -533,6 +533,12 @@ if (empty($reshook)) $object->set_billed(); } + elseif ($action == 'classifyclosed') + { + $object->fetch($id); + $object->setClosed(); + } + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails @@ -885,6 +891,7 @@ if ($action == 'create') //ship from preselected location $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number $deliverableQty=min($quantityToBeDelivered, $stock); + if ($deliverableQty < 0) $deliverableQty = 0; if (empty($conf->productbatch->enabled) || ! ($product->hasbatch() && is_object($product->stock_warehouse[$warehouse_id]))) { // Quantity to send @@ -1774,16 +1781,19 @@ else if ($id || $ref) { print ''.$langs->trans("CreateDeliveryOrder").''; } - // Close if (! empty($conf->facture->enabled) && $object->statut > 0) { if ($user->rights->expedition->creer && $object->statut > 0 && ! $object->billed) { - $label="Close"; + $label="Close"; $paramaction='classifyclosed'; // = Transferred/Received // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders - if (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $label="ClassifyBilled"; - print ''.$langs->trans($label).''; + if (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // TODO Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close. + { + $label="ClassifyBilled"; + $paramaction='classifybilled'; + } + print ''.$langs->trans($label).''; } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index a0ba1567c24..6ddf05401da 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -664,7 +664,7 @@ class Expedition extends CommonObject $langs->load("agenda"); // Loop on each product line to add a stock movement - // TODO possibilite d'expedier a partir d'une propale ou autre origine + // TODO in future, shipment lines may not be linked to order line $sql = "SELECT cd.fk_product, cd.subprice,"; $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock"; @@ -738,7 +738,7 @@ class Expedition extends CommonObject if (! $error && ! $notrigger) { // Call trigger - $result=$this->call_trigger('SHIPPING_VALIDATE',$user); + $result=$this->call_trigger('SHIPPING_VALIDATE',$user); // TODO Add option in workflow module on this trigger to close order if sum of shipment = product to ship of order if ($result < 0) { $error++; } // End call triggers } @@ -1795,11 +1795,11 @@ class Expedition extends CommonObject } /** - * Classify the shipping as invoiced + * Classify the shipping as closed * * @return int <0 if ko, >0 if ok */ - function set_billed() + function setClosed() { global $conf; @@ -1809,7 +1809,32 @@ class Expedition extends CommonObject $resql=$this->db->query($sql); if ($resql) { - //TODO: Add option/checkbox to set order billed if 100% of order is shipped + // TODO: Add option/checkbox to set order billed if 100% of order is shipped + $this->statut=2; + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) + * + * @return int <0 if ko, >0 if ok + */ + function set_billed() + { + global $conf; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; + + $resql=$this->db->query($sql); + if ($resql) + { $this->statut=2; $this->billed=1; return 1; diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 002930c276c..832107e7f6f 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -36,6 +36,8 @@ ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax1_type varchar(10) ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; +ALTER TABLE llx_expedition ADD COLUMN billed smallint DEFAULT 0; + CREATE TABLE llx_product_lot ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, diff --git a/htdocs/install/mysql/tables/llx_expedition.sql b/htdocs/install/mysql/tables/llx_expedition.sql index 8421bb1649c..12dba35f89d 100644 --- a/htdocs/install/mysql/tables/llx_expedition.sql +++ b/htdocs/install/mysql/tables/llx_expedition.sql @@ -40,8 +40,9 @@ create table llx_expedition fk_address integer DEFAULT NULL, -- delivery address (deprecated) fk_shipping_method integer, tracking_number varchar(50), - fk_statut smallint DEFAULT 0, - + fk_statut smallint DEFAULT 0, -- 0 = draft, 1 = validated, 2 = billed or closed depending on WORKFLOW_BILL_ON_SHIPMENT option + billed smallint DEFAULT 0, + height float, -- height width float, -- with size_units integer, -- unit of all sizes (height, width, depth) diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang index 3d12ad57612..a1ede43437d 100644 --- a/htdocs/langs/en_US/supplier_proposal.lang +++ b/htdocs/langs/en_US/supplier_proposal.lang @@ -1,7 +1,6 @@ # Dolibarr language file - Source file is en_US - supplier_proposal SupplierProposal=Supplier commercial proposals supplier_proposalDESC=Manage price requests to suppliers -SupplierProposalShort=Supplier proposals SupplierProposalNew=New request CommRequest=Price request CommRequests=Price requests