diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 8f6df313506..25c8d068ae1 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -269,10 +269,12 @@ else if ($action == 'add' && $user->rights->commande->creer) { if ($ret < 0) $error ++; - if (! $error) { + if (! $error) + { $object_id = $object->create($user); - if ($object_id > 0) { + if ($object_id > 0) + { dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); $classname = ucfirst($subelement); @@ -280,15 +282,20 @@ else if ($action == 'add' && $user->rights->commande->creer) { dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); $result = $srcobject->fetch($object->origin_id); - if ($result > 0) { + if ($result > 0) + { $lines = $srcobject->lines; if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - $lines = $srcobject->fetch_lines(); + { + $srcobject->fetch_lines(); + $lines = $srcobject->lines; + } $fk_parent_line = 0; $num = count($lines); - for($i = 0; $i < $num; $i ++) { + for($i = 0; $i < $num; $i ++) + { $label = (! empty($lines [$i]->label) ? $lines [$i]->label : ''); $desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle); $product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0); diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index bdb96718dfa..5332690e40b 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -97,7 +97,7 @@ if (($action == 'create' || $action == 'add') && empty($mesgs)) require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - + $langs->load('bills'); $langs->load('products'); $langs->load('main'); @@ -213,13 +213,17 @@ if (($action == 'create' || $action == 'add') && empty($mesgs)) $result=$objectsrc->fetch($orders_id[$ii]); if ($result > 0) { - if ($closeOrders) + if ($closeOrders) { $objectsrc->classifyBilled(); $objectsrc->setStatut(3); } $lines = $objectsrc->lines; - if (empty($lines) && method_exists($objectsrc,'fetch_lines')) $lines = $objectsrc->fetch_lines(); + if (empty($lines) && method_exists($objectsrc, 'fetch_lines')) + { + $objectsrc->fetch_lines(); + $lines = $objectsrc->lines; + } $fk_parent_line=0; $num=count($lines); for ($i=0;$i<$num;$i++) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8138c56450e..0e237af632c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -924,7 +924,11 @@ else if ($action == 'add' && $user->rights->facture->creer) if ($result > 0) { $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) $lines = $srcobject->fetch_lines(); + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + { + $srcobject->fetch_lines(); + $lines = $srcobject->lines; + } $fk_parent_line=0; $num=count($lines); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 7bcd7fcbc8d..38a2b3f1095 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -250,7 +250,11 @@ if ($action == 'add' && $user->rights->contrat->creer) { $srcobject->fetch_thirdparty(); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + if (empty($lines) && method_exists($srcobject,'fetch_lines')) + { + $srcobject->fetch_lines(); + $lines = $srcobject->lines; + } $fk_parent_line=0; $num=count($lines); @@ -337,10 +341,10 @@ if ($action == 'add' && $user->rights->contrat->creer) } else { - + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - + $result = $object->create($user); if ($result > 0) { @@ -715,7 +719,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra $error ++; if (! $error) { - + $result = $object->insertExtraFields(); if ($result < 0) { $error ++; @@ -948,7 +952,7 @@ if ($action == 'create') // Other attributes $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + // Other attributes if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); @@ -1112,7 +1116,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + $res = $object->fetch_optionals($object->id, $extralabels); if (empty($reshook) && ! empty($extrafields->attribute_label)) { foreach ($extrafields->attribute_label as $key => $label) { @@ -1132,16 +1136,16 @@ else if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) { $value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); } - + if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) { print '
'; } else { @@ -1153,9 +1157,9 @@ else } } } - - - + + + print ""; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index f676c1b2138..c11c1d549a9 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -112,7 +112,6 @@ if ($action == 'add') $classname = ucfirst($object->origin); $objectsrc = new $classname($db); $objectsrc->fetch($object->origin_id); - //$object->fetch_lines(); $object->socid = $objectsrc->socid; $object->ref_customer = $objectsrc->ref_client; @@ -717,7 +716,6 @@ if ($action == 'create') * Lignes de commandes */ - //$lines = $object->fetch_lines(1); $numAsked = count($object->lines); print '