diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index bda67f809fa..74e79e0e41b 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -786,9 +786,10 @@ if (empty($reshook)) } /* - * Mise a jour d'une ligne dans la commande - */ - else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('save') == $langs->trans('Save')) { + * Update a line + */ + else if ($action == 'updateline' && $user->rights->commande->creer && GETPOST('save') == $langs->trans('Save')) + { // Clean parameters $date_start=''; $date_end=''; @@ -891,7 +892,7 @@ if (empty($reshook)) } } - else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('cancel') == $langs->trans('Cancel')) { + else if ($action == 'updateline' && $user->rights->commande->creer && GETPOST('cancel') == $langs->trans('Cancel')) { header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -2101,7 +2102,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '
- + '; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index da9971b1b4e..a9f20b0edb3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2137,7 +2137,7 @@ abstract class CommonObject $fieldstatus="fk_statut"; if ($elementTable == 'user') $fieldstatus="statut"; if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts"; - + $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql.= " SET ".$fieldstatus." = ".$status; // If status = 1 = validated, update also fk_user_valid @@ -2572,7 +2572,12 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf, $hookmanager, $inputalsopricewithtax, $langs, $user; + global $conf, $hookmanager, $inputalsopricewithtax, $usermargins, $langs, $user; + + # Define usemargins + $usemargins=0; + if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1; + print ''; @@ -2599,7 +2604,7 @@ abstract class CommonObject print ''; } - if (! empty($conf->margin->enabled) && empty($user->societe_id)) + if ($usermargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) { if ($conf->global->MARGIN_TYPE == "1") print ''.$langs->trans('BuyingPrice').''; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 22ca6e4171e..94a2e5fa975 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -208,6 +208,8 @@ class DoliDBPgsql extends DoliDB $line=preg_replace('/tinytext/i','text',$line); $line=preg_replace('/mediumtext/i','text',$line); + $line=preg_replace('/text\([0-9]+\)/i','text',$line); + // change not null datetime field to null valid ones // (to support remapping of "zero time" to null $line=preg_replace('/datetime not null/i','datetime',$line); diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index bce94c70a57..8a98ac2f613 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -263,7 +263,8 @@ else { table_element_line=='commandedet') { $newline = new OrderLine($this->db); } @@ -276,6 +277,12 @@ else { elseif ($this->table_element_line=='contratdet') { $newline = new ContratLigne($this->db); } + elseif ($this->table_element_line=='commande_fournisseurdet') { + $newline = new CommandeFournisseurLigne($this->db); + } + elseif ($this->table_element_line=='facture_fourn_det') { + $newline = new FactureFournisseurLigne($this->db); + } if (is_object($newline)) { print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8)); } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index ae2238e06f2..d844cc09c76 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -199,7 +199,8 @@ $coldisplay=-1; // We remove first td showOptionals($extrafieldsline,'edit',array('style'=>$bc[$var],'colspan'=>$coldisplay)); } ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 2e1cc0f3678..dab7361eea9 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -27,18 +27,17 @@ * $forceall (0 by default, 1 for supplier invoices/orders) * $senderissupplier (0 by default, 1 for supplier invoices/orders) * $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) * * $type, $text, $description, $line */ -$usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; - -global $forceall, $senderissupplier, $inputalsopricewithtax; +global $forceall, $senderissupplier, $inputalsopricewithtax, $usemargins; if (empty($dateSelector)) $dateSelector=0; if (empty($forceall)) $forceall=0; if (empty($senderissupplier)) $senderissupplier=0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; +if (empty($usemargins)) $usemargins=0; ?> @@ -83,7 +82,8 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; } else { - if ($line->fk_product > 0) { + if ($line->fk_product > 0) + { echo $form->textwithtooltip($text,$description,3,'','',$i,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); @@ -96,7 +96,9 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; } - } else { + } + else + { if ($type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); @@ -145,17 +147,19 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; print '' . $line->situation_percent . '%'; } - if (! empty($conf->margin->enabled) && empty($user->societe_id)) { - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); - ?> + if ($usermargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) + { + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); + ?> pa_ht); ?> - global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) {?> + global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?> pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?> - global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> + global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> marque_tx, null, null, null, null, $rounding).'%'; ?> - + special_code == 3) { ?> trans('Option'); ?> diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index ff36c171298..0cc08220a49 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1814,3 +1814,15 @@ class FactureFournisseur extends CommonInvoice } } + + + +/** + * Class to manage line invoices + */ +class FactureFournisseurLigne extends CommonInvoiceLine +{ + + +} + diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index e6a5aafad38..8c0b4fd5900 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -63,6 +63,8 @@ $confirm = GETPOST('confirm','alpha'); $comclientid = GETPOST('comid','int'); $socid = GETPOST('socid','int'); $projectid = GETPOST('projectid','int'); +$cancel = GETPOST('cancel','alpha'); +$lineid = GETPOST('lineid', 'int'); //PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -113,6 +115,8 @@ $permissionnote=$user->rights->fournisseur->commande->creer; // Used by the incl * Actions */ +if ($cancel) $action=''; + $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -402,7 +406,7 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) /* * Mise a jour d'une ligne dans la commande */ -if ($action == 'update_line' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel')) +if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel')) { if ($_POST["elrowid"]) { @@ -1693,23 +1697,32 @@ elseif (! empty($object->id)) /* * Lines */ + //$result = $object->getLinesArray(); - print ' id.(($action != 'edit_line')?'#add':'#line_'.GETPOST('lineid')).'" method="POST"> + print ' - + - '; + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } print ''; - $num = count($object->lines); - $i = 0; $total = 0; + // Show object lines + $inputalsopricewithtax=1; + if (! empty($object->lines)) + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); + $num = count($object->lines); + +/* + $i = 0; $total = 0; if ($num) { print ''; @@ -1746,7 +1759,7 @@ elseif (! empty($object->id)) } // Edit line - if ($action != 'edit_line' || $_GET['rowid'] != $line->id) + if ($action != 'editline' || $_GET['rowid'] != $line->id) { print ''; @@ -1808,7 +1821,7 @@ elseif (! empty($object->id)) if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) { - print ''; @@ -1825,7 +1838,7 @@ elseif (! empty($object->id)) } // Edit line - if ($action == 'edit_line' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id)) + if ($action == 'editline' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id)) { print "\n"; print ''; @@ -1885,9 +1898,9 @@ elseif (! empty($object->id)) } $i++; } - +*/ // Form to add new line - if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action != 'edit_line') + if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action != 'editline') { // Add free products/services form global $forceall, $senderissupplier, $dateSelector; @@ -2235,7 +2248,7 @@ elseif (! empty($object->id)) // modified by hook if (empty($reshook)) { - if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete') + if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete') { print '
'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 540c7dfe035..df6ab1e73d2 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -57,6 +57,8 @@ $id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); $action = GETPOST("action"); $confirm = GETPOST("confirm"); $ref = GETPOST('ref','alpha'); +$cancel = GETPOST('cancel','alpha'); +$lineid = GETPOST('lineid', 'int'); //PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -90,6 +92,8 @@ $permissionnote=$user->rights->fournisseur->facture->creer; // Used by the inclu * Actions */ +if ($cancel) $action=''; + $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -503,12 +507,11 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) } // Edit line -elseif ($action == 'update_line' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'updateline' && $user->rights->fournisseur->facture->creer) { - // TODO Missing transaction - if (GETPOST('etat') == '1' && ! GETPOST('cancel')) // si on valide la modification - { - $object->fetch($id); + $db->begin(); + + $object->fetch($id); $object->fetch_thirdparty(); if ($_POST['puht']) @@ -547,12 +550,13 @@ elseif ($action == 'update_line' && $user->rights->fournisseur->facture->creer) if ($result >= 0) { unset($_POST['label']); + $db->commit(); } else { + $db->rollback(); setEventMessage($object->error,'errors'); } - } } elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer) @@ -1954,11 +1958,10 @@ else $cols = 4; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - print '
id.'#'.$line->id.'">'; + print 'id.'#'.$line->id.'">'; print img_edit(); print '
'; + print '
'; if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - print '
'; $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; @@ -1976,23 +1979,31 @@ else /* * Lines */ + //$result = $object->getLinesArray(); - print ' id.(($action != 'edit_line')?'#add':'#line_'.GETPOST('lineid')).'" method="POST"> + print ' - + - - '; + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } - print '
'; - print ''; - $var=1; - $num=count($object->lines); + print '
'; + + // Show object lines + if (! empty($object->lines)) + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); + + $num=count($object->lines); + + /* + $var=1; for ($i = 0; $i < $num; $i++) { if ($i == 0) @@ -2029,7 +2040,7 @@ else $var=!$var; // Edit line - if ($object->statut == 0 && $action == 'edit_line' && $_GET['etat'] == '0' && $_GET['lineid'] == $object->lines[$i]->rowid) + if ($object->statut == 0 && $action == 'editline' && $_GET['lineid'] == $object->lines[$i]->rowid) { print ''; @@ -2156,7 +2167,7 @@ else } print ''; @@ -2172,9 +2183,9 @@ else } } - +*/ // Form to add new line - if ($object->statut == 0 && $action != 'edit_line') + if ($object->statut == 0 && $action != 'editline') { global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; $forceall=1; $senderissupplier=1; $dateSelector=0; $inputalsopricewithtax=1; @@ -2195,6 +2206,7 @@ else print '
'; - if ($object->statut == 0) print 'lines[$i]->rowid.'">'.img_edit().''; + if ($object->statut == 0) print 'lines[$i]->rowid.'">'.img_edit().''; else print ' '; print '
'; + print '
'; dol_fiche_end(); diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index c09c434d27e..41c84fddeaa 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -209,3 +209,13 @@ create table llx_commande_fournisseurdet_extrafields ALTER TABLE llx_commande_fournisseurdet_extrafields ADD INDEX idx_commande_fournisseurdet_extrafields (fk_object); +create table llx_facture_fourn_det_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_facture_fourn_det_extrafields ADD INDEX idx_facture_fourn_det_extrafields (fk_object); +