diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 29b22f8dbd2..3119205fda8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -371,11 +371,11 @@ else if ($action == 'add' && $user->rights->commande->creer) { // If some invoice's lines already known $NBLINES = 8; for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST ['idprod' . $i]) { + if ($_POST['idprod' . $i]) { $xid = 'idprod' . $i; $xqty = 'qty' . $i; $xremise = 'remise_percent' . $i; - $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); + $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); } } } @@ -546,7 +546,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); + unset($_POST["options_" . $key]); } } @@ -725,23 +725,23 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - unset($_POST ['prod_entry_mode']); + unset($_POST['prod_entry_mode']); - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); - unset($_POST ['np_marginRate']); - unset($_POST ['np_markRate']); - unset($_POST ['dp_desc']); - unset($_POST ['idprod']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprod']); unset($_POST['date_starthour']); unset($_POST['date_startmin']); @@ -796,7 +796,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); + unset($_POST["options_" . $key]); } } @@ -850,18 +850,18 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['productid']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); } else { setEventMessage($object->error, 'errors'); } @@ -1699,6 +1699,8 @@ if ($action == 'create' && $user->rights->commande->creer) { $author = new User($db); $author->fetch($object->user_author_id); + $res = $object->fetch_optionals($object->id, $extralabels); + $head = commande_prepare_head($object); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); @@ -2120,30 +2122,38 @@ if ($action == 'create' && $user->rights->commande->creer) { } // Other attributes (TODO Move this into an include) - $res = $object->fetch_optionals($object->id, $extralabels); $parameters = array('colspan' => ' colspan="3"'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by - // hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach ($extrafields->attribute_label as $key => $label) { - if ($action == 'edit_extras') { - $value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]); - } else { - $value = $object->array_options ["options_" . $key]; + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + foreach ($extrafields->attribute_label as $key => $label) + { + if ($action == 'edit_extras') + { + $value = (isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); } - if ($extrafields->attribute_type [$key] == 'separate') { + else + { + $value = $object->array_options["options_" . $key]; + } + + if ($extrafields->attribute_type[$key] == 'separate') + { print $extrafields->showSeparator($key); - } else { + } + else + { print 'attribute_required [$key])) - print ' class="fieldrequired"'; + if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"'; print '>' . $label . ''; // Convert date into timestamp format - 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 (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) { + if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) + { print '
'; print ''; print ''; @@ -2154,7 +2164,9 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; print '
'; - } else { + } + else + { print $extrafields->showOutputField($key, $value); if ($object->statut == 0 && $user->rights->commande->creer) print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ''; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index ba3cb7e9de0..72cc500e187 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1188,19 +1188,20 @@ if ($action=="create") } elseif (! empty($object->id)) { - $author = new User($db); - $author->fetch($object->user_author_id); - $societe = new Fournisseur($db); $result=$societe->fetch($object->socid); if ($result < 0) dol_print_error($db); + $author = new User($db); + $author->fetch($object->user_author_id); + + $res=$object->fetch_optionals($object->id,$extralabels); + $head = ordersupplier_prepare_head($object); $title=$langs->trans("SupplierOrder"); dol_fiche_head($head, 'card', $title, 0, 'order'); - $res=$object->fetch_optionals($object->id,$extralabels); /* * Confirmation de la suppression de la commande @@ -1482,24 +1483,19 @@ elseif (! empty($object->id)) print ''; } - // Other attributes + // Other attributes (TODO Move this into an include) $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - if ($action == 'edit_extras') - { - print '
'; - print ''; - print ''; - print ''; - } - foreach($extrafields->attribute_label as $key=>$label) { - if ($action == 'edit_extras') { + if ($action == 'edit_extras') + { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - } else { + } + else + { $value=$object->array_options["options_".$key]; } @@ -1518,15 +1514,25 @@ elseif (! empty($object->id)) $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->fournisseur->commande->creer) + if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) { - print $extrafields->showInputField($key,$value); + print ''; + print ''; + print ''; + print ''; + print ''; + + print $extrafields->showInputField($key, $value); + + print ''; + print '
'; } else { - print $extrafields->showOutputField($key,$value); + print $extrafields->showOutputField($key, $value); + if ($object->statut == 0 && $user->rights->commande->creer) + print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ''; } - print ''."\n"; } }