|
@@ -72,7 +72,7 @@ if (!empty($conf->productbatch->enabled)) {
|
|
|
}
|
|
|
|
|
|
$origin = GETPOST('origin', 'alpha') ?GETPOST('origin', 'alpha') : 'reception'; // Example: commande, propal
|
|
|
-$origin_id = GETPOST('id', 'int') ?GETPOST('id', 'int') : '';
|
|
|
+$origin_id = GETPOST('id', 'int') ? GETPOST('id', 'int') : '';
|
|
|
$id = $origin_id;
|
|
|
if (empty($origin_id)) {
|
|
|
$origin_id = GETPOST('origin_id', 'int'); // Id of order or propal
|
|
@@ -86,12 +86,12 @@ if (empty($origin_id)) {
|
|
|
$ref = GETPOST('ref', 'alpha');
|
|
|
$line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : '';
|
|
|
|
|
|
-$action = GETPOST('action', 'alpha');
|
|
|
+$action = GETPOST('action', 'alpha');
|
|
|
//Select mail models is same action as presend
|
|
|
if (GETPOST('modelselected')) {
|
|
|
$action = 'presend';
|
|
|
}
|
|
|
-$confirm = GETPOST('confirm', 'alpha');
|
|
|
+$confirm = GETPOST('confirm', 'alpha');
|
|
|
$cancel = GETPOST('cancel', 'alpha');
|
|
|
|
|
|
//PDF
|
|
@@ -117,7 +117,6 @@ $permissiondellink = $user->rights->reception->creer; // Used by the include of
|
|
|
|
|
|
$date_delivery = dol_mktime(GETPOST('date_deliveryhour', 'int'), GETPOST('date_deliverymin', 'int'), 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int'));
|
|
|
|
|
|
-$object = new Reception($db);
|
|
|
if ($id > 0 || !empty($ref)) {
|
|
|
$object->fetch($id, $ref);
|
|
|
$object->fetch_thirdparty();
|
|
@@ -725,13 +724,13 @@ if ($action == 'create') {
|
|
|
$classname = ucfirst($origin);
|
|
|
}
|
|
|
|
|
|
- $object = new $classname($db);
|
|
|
- if ($object->fetch($origin_id)) { // This include the fetch_lines
|
|
|
+ $objectsrc = new $classname($db);
|
|
|
+ if ($objectsrc->fetch($origin_id)) { // This include the fetch_lines
|
|
|
$soc = new Societe($db);
|
|
|
- $soc->fetch($object->socid);
|
|
|
+ $soc->fetch($objectsrc->socid);
|
|
|
|
|
|
$author = new User($db);
|
|
|
- $author->fetch($object->user_author_id);
|
|
|
+ $author->fetch($objectsrc->user_author_id);
|
|
|
|
|
|
if (!empty($conf->stock->enabled)) {
|
|
|
$entrepot = new Entrepot($db);
|
|
@@ -741,8 +740,7 @@ if ($action == 'create') {
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
|
print '<input type="hidden" name="action" value="add">';
|
|
|
print '<input type="hidden" name="origin" value="'.$origin.'">';
|
|
|
- print '<input type="hidden" name="origin_id" value="'.$object->id.'">';
|
|
|
- print '<input type="hidden" name="ref_int" value="'.$object->ref_int.'">';
|
|
|
+ print '<input type="hidden" name="origin_id" value="'.$objectsrc->id.'">';
|
|
|
if (GETPOST('entrepot_id', 'int')) {
|
|
|
print '<input type="hidden" name="entrepot_id" value="'.GETPOST('entrepot_id', 'int').'">';
|
|
|
}
|
|
@@ -754,10 +752,10 @@ if ($action == 'create') {
|
|
|
// Ref
|
|
|
print '<tr><td class="titlefieldcreate fieldrequired">';
|
|
|
if ($origin == 'supplierorder' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled))) {
|
|
|
- print $langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id.'">'.img_object($langs->trans("ShowOrder"), 'order').' '.$object->ref;
|
|
|
+ print $langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$objectsrc->id.'">'.img_object($langs->trans("ShowOrder"), 'order').' '.$objectsrc->ref;
|
|
|
}
|
|
|
if ($origin == 'propal' && !empty($conf->propal->enabled)) {
|
|
|
- print $langs->trans("RefProposal").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/comm/card.php?id='.$object->id.'">'.img_object($langs->trans("ShowProposal"), 'propal').' '.$object->ref;
|
|
|
+ print $langs->trans("RefProposal").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/comm/card.php?id='.$objectsrc->id.'">'.img_object($langs->trans("ShowProposal"), 'propal').' '.$objectsrc->ref;
|
|
|
}
|
|
|
print '</a></td>';
|
|
|
print "</tr>\n";
|
|
@@ -770,7 +768,7 @@ if ($action == 'create') {
|
|
|
print $langs->trans('RefSupplier');
|
|
|
}
|
|
|
print '</td><td colspan="3">';
|
|
|
- print '<input type="text" name="ref_supplier" value="'.$object->ref_supplier.'" />';
|
|
|
+ print '<input type="text" name="ref_supplier" value="'.$objectsrc->ref_supplier.'" />';
|
|
|
print '</td>';
|
|
|
print '</tr>';
|
|
|
|
|
@@ -782,8 +780,8 @@ if ($action == 'create') {
|
|
|
// Project
|
|
|
if (!empty($conf->projet->enabled)) {
|
|
|
$projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0;
|
|
|
- if (empty($projectid) && !empty($object->fk_project)) {
|
|
|
- $projectid = $object->fk_project;
|
|
|
+ if (empty($projectid) && !empty($objectsrc->fk_project)) {
|
|
|
+ $projectid = $objectsrc->fk_project;
|
|
|
}
|
|
|
if ($origin == 'project') {
|
|
|
$projectid = ($originid ? $originid : 0);
|
|
@@ -802,7 +800,7 @@ if ($action == 'create') {
|
|
|
// Date delivery planned
|
|
|
print '<tr><td>'.$langs->trans("DateDeliveryPlanned").'</td>';
|
|
|
print '<td colspan="3">';
|
|
|
- $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date); // $date_delivery comes from GETPOST
|
|
|
+ $date_delivery = ($date_delivery ? $date_delivery : $objectsrc->delivery_date); // $date_delivery comes from GETPOST
|
|
|
print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1);
|
|
|
print "</td>\n";
|
|
|
print '</tr>';
|
|
@@ -810,15 +808,15 @@ if ($action == 'create') {
|
|
|
// Note Public
|
|
|
print '<tr><td>'.$langs->trans("NotePublic").'</td>';
|
|
|
print '<td colspan="3">';
|
|
|
- $doleditor = new DolEditor('note_public', $object->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
|
|
|
+ $doleditor = new DolEditor('note_public', $objectsrc->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
|
|
|
print $doleditor->Create(1);
|
|
|
print "</td></tr>";
|
|
|
|
|
|
// Note Private
|
|
|
- if ($object->note_private && !$user->socid) {
|
|
|
+ if ($objectsrc->note_private && !$user->socid) {
|
|
|
print '<tr><td>'.$langs->trans("NotePrivate").'</td>';
|
|
|
print '<td colspan="3">';
|
|
|
- $doleditor = new DolEditor('note_private', $object->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
|
|
|
+ $doleditor = new DolEditor('note_private', $objectsrc->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
|
|
|
print $doleditor->Create(1);
|
|
|
print "</td></tr>";
|
|
|
}
|
|
@@ -861,15 +859,15 @@ if ($action == 'create') {
|
|
|
|
|
|
// Other attributes
|
|
|
$parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid'=>$socid);
|
|
|
- $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook
|
|
|
+ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $objectsrc may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
|
- // Here $object can be of an object Order
|
|
|
+ // Here $object can be of an object Reception
|
|
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
|
|
if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) {
|
|
|
// copy from order
|
|
|
- if ($object->fetch_optionals() > 0) {
|
|
|
- $recept->array_options = array_merge($recept->array_options, $object->array_options);
|
|
|
+ if ($objectsrc->fetch_optionals() > 0) {
|
|
|
+ $recept->array_options = array_merge($recept->array_options, $objectsrc->array_options);
|
|
|
}
|
|
|
print $object->showOptionals($extrafields, 'edit', $parameters);
|
|
|
}
|
|
@@ -877,9 +875,9 @@ if ($action == 'create') {
|
|
|
// Incoterms
|
|
|
if (!empty($conf->incoterm->enabled)) {
|
|
|
print '<tr>';
|
|
|
- print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->label_incoterms, 1).'</label></td>';
|
|
|
+ print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->label_incoterms, 1).'</label></td>';
|
|
|
print '<td colspan="3" class="maxwidthonsmartphone">';
|
|
|
- print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''));
|
|
|
+ print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : ''));
|
|
|
print '</td></tr>';
|
|
|
}
|
|
|
|
|
@@ -898,12 +896,14 @@ if ($action == 'create') {
|
|
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
|
|
-
|
|
|
// Reception lines
|
|
|
$numAsked = 0;
|
|
|
$dispatchLines = array();
|
|
|
foreach ($_POST as $key => $value) {
|
|
|
+ // If create form is coming from the button "Create Reception" of previous page
|
|
|
+
|
|
|
// without batch module enabled
|
|
|
+ $reg = array();
|
|
|
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
|
|
|
$numAsked++;
|
|
|
|
|
@@ -934,6 +934,25 @@ if ($action == 'create') {
|
|
|
$fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2];
|
|
|
$dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha'));
|
|
|
}
|
|
|
+
|
|
|
+ // If create form is coming from same page post was sent but an error occured
|
|
|
+ if (preg_match('/^productid([0-9]+)$/i', $key, $reg)) {
|
|
|
+ $numAsked++;
|
|
|
+
|
|
|
+ // eat-by date dispatch
|
|
|
+ // $numline=$reg[2] + 1; // line of product
|
|
|
+ $numline = $numAsked;
|
|
|
+ $prod = 'productid'.$reg[1];
|
|
|
+ $comment = 'comment'.$reg[1];
|
|
|
+ $qty = 'qtyl'.$reg[1];
|
|
|
+ $ent = 'entl'.$reg[1];
|
|
|
+ $pu = 'pul'.$reg[1];
|
|
|
+ $lot = 'batch'.$reg[1];
|
|
|
+ $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo'.$reg[1].'month', 'int'), GETPOST('dluo'.$reg[1].'day', 'int'), GETPOST('dluo'.$reg[1].'year', 'int'));
|
|
|
+ $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc'.$reg[1].'month', 'int'), GETPOST('dlc'.$reg[1].'day', 'int'), GETPOST('dlc'.$reg[1].'year', 'int'));
|
|
|
+ $fk_commandefourndet = 'fk_commandefournisseurdet'.$reg[1];
|
|
|
+ $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST($comment), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha'));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -961,7 +980,7 @@ if ($action == 'create') {
|
|
|
print '<table class="noborder centpercent">';
|
|
|
|
|
|
// Load receptions already done for same order
|
|
|
- $object->loadReceptions();
|
|
|
+ $objectsrc->loadReceptions();
|
|
|
|
|
|
if ($numAsked) {
|
|
|
print '<tr class="liste_titre">';
|
|
@@ -993,14 +1012,13 @@ if ($action == 'create') {
|
|
|
$indiceAsked = 1;
|
|
|
while ($indiceAsked <= $numAsked) {
|
|
|
$product = new Product($db);
|
|
|
- foreach ($object->lines as $supplierLine) {
|
|
|
+ foreach ($objectsrc->lines as $supplierLine) {
|
|
|
if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) {
|
|
|
$line = $supplierLine;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// Show product and description
|
|
|
$type = $line->product_type ? $line->product_type : $line->fk_product_type;
|
|
|
// Try to enhance type detection using date_start and date_end for free lines where type
|
|
@@ -1012,7 +1030,7 @@ if ($action == 'create') {
|
|
|
$type = 1;
|
|
|
}
|
|
|
|
|
|
- print '<!-- line '.$line->rowid.' for product -->'."\n";
|
|
|
+ print '<!-- line fk_commandefourndet='.$line->id.' for product='.$line->fk_product.' -->'."\n";
|
|
|
print '<tr class="oddeven">'."\n";
|
|
|
|
|
|
|
|
@@ -1024,6 +1042,7 @@ if ($action == 'create') {
|
|
|
|
|
|
print '<td>';
|
|
|
print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne
|
|
|
+ print '<input type="hidden" name="productid'.$indiceAsked.'" value="'.$line->fk_product.'">';
|
|
|
|
|
|
// Show product and description
|
|
|
$product_static->type = $line->fk_product_type;
|
|
@@ -1067,7 +1086,7 @@ if ($action == 'create') {
|
|
|
|
|
|
// Comment
|
|
|
//$defaultcomment = 'Line create from order line id '.$line->id;
|
|
|
- $defaultcomment = '';
|
|
|
+ $defaultcomment = $dispatchLines[$indiceAsked]['comment'];
|
|
|
print '<td>';
|
|
|
print '<input type="text" class="maxwidth100" name="comment'.$indiceAsked.'" value="'.$defaultcomment.'">';
|
|
|
print '</td>';
|
|
@@ -1075,13 +1094,14 @@ if ($action == 'create') {
|
|
|
// Qty
|
|
|
print '<td class="center">'.$line->qty;
|
|
|
print '<input type="hidden" name="fk_commandefournisseurdet'.$indiceAsked.'" value="'.$line->id.'">';
|
|
|
+ print '<input type="hidden" name="pul'.$indiceAsked.'" value="'.$line->pu_ht.'">';
|
|
|
print '<input name="qtyasked'.$indiceAsked.'" id="qtyasked'.$indiceAsked.'" type="hidden" value="'.$line->qty.'">';
|
|
|
print '</td>';
|
|
|
$qtyProdCom = $line->qty;
|
|
|
|
|
|
// Qty already received
|
|
|
print '<td class="center">';
|
|
|
- $quantityDelivered = $object->receptions[$line->id];
|
|
|
+ $quantityDelivered = $objectsrc->receptions[$line->id];
|
|
|
print $quantityDelivered;
|
|
|
print '<input name="qtydelivered'.$indiceAsked.'" id="qtydelivered'.$indiceAsked.'" type="hidden" value="'.$quantityDelivered.'">';
|
|
|
print '</td>';
|