FIX Debug feature orderstoinvoice for suppliers

This commit is contained in:
Laurent Destailleur 2019-09-14 18:21:37 +02:00
parent bac1e7133a
commit 3caa1bd43c
4 changed files with 60 additions and 39 deletions

View File

@ -605,8 +605,9 @@ if ($object->id > 0)
$sql2.= ' WHERE c.fk_soc = s.rowid'; $sql2.= ' WHERE c.fk_soc = s.rowid';
$sql2.= " AND c.entity IN (".getEntity('commande_fournisseur').")"; $sql2.= " AND c.entity IN (".getEntity('commande_fournisseur').")";
$sql2.= ' AND s.rowid = '.$object->id; $sql2.= ' AND s.rowid = '.$object->id;
// Show orders with status validated, shipping started and delivered (well any order we can bill) // Show orders with status validated, shipping started and delivered (even if any order we can bill)
$sql2.= " AND c.fk_statut IN (5)"; //$sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")";
$sql2.= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY.")";
$sql2.= " AND c.billed = 0"; $sql2.= " AND c.billed = 0";
// Find order that are not already invoiced // Find order that are not already invoiced
// just need to check received status because we have the billed status now // just need to check received status because we have the billed status now
@ -826,7 +827,7 @@ if ($object->id > 0)
{ {
if (! empty($orders2invoice) && $orders2invoice > 0) if (! empty($orders2invoice) && $orders2invoice > 0)
{ {
if ($object->status == 1) if ($object->status == 1) // Company is open
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/orderstoinvoice.php?socid='.$object->id.'">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
} }
@ -835,7 +836,7 @@ if ($object->id > 0)
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
} }
} }
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice").' ('.$langs->trans("WithReceptionFinished").')').'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
} }
// Add action // Add action

View File

@ -2494,11 +2494,18 @@ elseif (! empty($object->id))
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
} }
elseif (!empty($object->linkedObjectsIds['invoice_supplier'])) else
{ {
if ($user->rights->fournisseur->facture->creer) if (!empty($object->linkedObjectsIds['invoice_supplier']))
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>'; if ($user->rights->fournisseur->facture->creer)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
}
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NeedAtLeastOneInvoice")).'">'.$langs->trans("ClassifyBilled").'</a>';
} }
} }
} }

View File

@ -73,18 +73,27 @@ $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label('facture_fourn'); $extralabels=$extrafields->fetch_name_optionals_label('facture_fourn');
if ($action == 'create') if ($action == 'create')
{ {
if (! is_array($selected)) if (! GETPOST('createbill'))
{ {
$error++; $action = '';
setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); }
} else { else
$origin = GETPOST('origin'); {
$originid = GETPOST('originid'); if (! is_array($selected))
{
//$error++;
setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors');
$action = '';
} else {
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int');
}
} }
} }
@ -286,7 +295,6 @@ if (($action == 'create' || $action == 'add') && ! $error) {
$html = new Form($db); $html = new Form($db);
$htmlother = new FormOther($db); $htmlother = new FormOther($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$companystatic = new Societe($db);
// Mode creation // Mode creation
if ($action == 'create' && !$error) { if ($action == 'create' && !$error) {
@ -324,6 +332,8 @@ if ($action == 'create' && !$error) {
print '<input name="ref_int" type="hidden" value="' . $ref_int . '">'; print '<input name="ref_int" type="hidden" value="' . $ref_int . '">';
print '<input type="hidden" name="origin" value="' . GETPOST('origin') . '">'; print '<input type="hidden" name="origin" value="' . GETPOST('origin') . '">';
print '<input type="hidden" name="originid" value="' . GETPOST('originid') . '">'; print '<input type="hidden" name="originid" value="' . GETPOST('originid') . '">';
print '<input type="hidden" name="socid" value="' . $soc->id . '">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
@ -333,13 +343,6 @@ if ($action == 'create' && !$error) {
print '<tr><td class="fieldrequired">' . $langs->trans('RefSupplier') . '</td><td><input name="ref_supplier" value="' . dol_escape_htmltag(isset($_POST['ref_supplier']) ? GETPOST('ref_supplier', 'alpha', 2) : '') . '" type="text"></td>'; print '<tr><td class="fieldrequired">' . $langs->trans('RefSupplier') . '</td><td><input name="ref_supplier" value="' . dol_escape_htmltag(isset($_POST['ref_supplier']) ? GETPOST('ref_supplier', 'alpha', 2) : '') . '" type="text"></td>';
print '</tr>'; print '</tr>';
// Third party
print '<tr><td class="fieldrequired">' . $langs->trans('Customer') . '</td><td colspan="2">';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="' . $soc->id . '">';
print '</td>';
print '</tr>' . "\n";
// Date invoice // Date invoice
print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td colspan="2">'; print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td colspan="2">';
print $html->selectDate('', '', '', '', '', "add", 1, 1); print $html->selectDate('', '', '', '', '', "add", 1, 1);
@ -387,18 +390,19 @@ if ($action == 'create' && !$error) {
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>'; print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>';
print '<td valign="top" colspan="2">'; print '<td colspan="2">';
print '<textarea name="note_public" wrap="soft" class="quatrevingtpercent" rows="' . ROWS_3 . '">'; print '<textarea name="note_public" wrap="soft" class="quatrevingtpercent" rows="' . ROWS_3 . '">';
print $langs->trans("Orders") . ": " . implode(', ', $listoforders); print $langs->trans("Orders") . ": " . implode(', ', $listoforders);
print '</textarea></td></tr>'; print '</textarea></td></tr>';
// Private note // Private note
if (empty($user->societe_id)) { if (empty($user->societe_id)) {
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>'; print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>';
print '<td valign="top" colspan="2">'; print '<td colspan="2">';
print '<textarea name="note" wrap="soft" cols="70" rows="' . ROWS_3 . '">'; print '<textarea name="note" wrap="soft" cols="70" rows="' . ROWS_3 . '">';
print '</textarea></td></tr>'; print '</textarea></td></tr>';
@ -406,10 +410,10 @@ if ($action == 'create' && !$error) {
print '</table>'; print '</table>';
while ( $i < $n ) { while ($i < $n) {
print '<input type="hidden" name="orders_to_invoice[]" value="' . $orders_id[$i] . '">'; print '<input type="hidden" name="orders_to_invoice[]" value="' . $orders_id[$i] . '">';
$i ++; $i++;
} }
// Button "Create Draft" // Button "Create Draft"
@ -465,10 +469,16 @@ if (($action != 'create' && $action != 'add') && !$error) {
} }
// Date filter // Date filter
if ($date_start && $date_end) //$sql.= dolSqlDateFilter("c.date_commande", GETPOST("date_startday", 'int'), GETPOST("date_startmonth", 'int'), GETPOST("date_startyear", 'int'));
$sql .= " AND c.date_commande >= '" . $db->idate($date_start) . "' AND c.date_commande <= '" . $db->idate($date_end) . "'"; //$sql.= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear);
if ($date_starty && $date_endy) if ($date_start)
$sql .= " AND c.date_livraison >= '" . $db->idate($date_starty) . "' AND c.date_livraison <= '" . $db->idate($date_endy) . "'"; $sql .= " AND c.date_commande >= '" . $db->idate($date_start) . "'";
if ($date_end)
$sql .= " AND c.date_commande <= '" . $db->idate($date_end) . "'";
if ($date_starty)
$sql .= " AND c.date_livraison >= '" . $db->idate($date_starty) . "'";
if ($date_endy)
$sql .= " AND c.date_livraison <= '" . $db->idate($date_endy) . "'";
if (! empty($sref_client)) { if (! empty($sref_client)) {
$sql .= natural_search('c.ref_supplier', $sref_client); $sql .= natural_search('c.ref_supplier', $sref_client);
@ -484,21 +494,21 @@ if (($action != 'create' && $action != 'add') && !$error) {
} }
$title = $langs->trans('ListOfSupplierOrders'); $title = $langs->trans('ListOfSupplierOrders');
$title .= ' - ' . $langs->trans('StatusOrderReceivedAllShort'); $title .= ' - ' . $langs->trans('StatusOrderReceivedAllShort');
$title .= ' - ' . $soc->getNomUrl(1, 'supplier');
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
print load_fiche_titre($title); print load_fiche_titre($title);
$i = 0; $i = 0;
$period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0); $period = $html->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 0);
$periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0); $periodely = $html->selectDate($date_starty, 'date_start_dely', 0, 0, 1, '', 1, 0) . ' - ' . $html->selectDate($date_endy, 'date_end_dely', 0, 0, 1, '', 1, 0);
if (! empty($socid)) {
// Company
$companystatic->id = $socid;
$companystatic->nom = $soc->nom;
print '<h3>' . $companystatic->getNomUrl(1, 'customer') . '</h3>';
}
print '<form name="orders2invoice" method="GET" action="orderstoinvoice.php">'; print '<form name="orders2invoice" method="GET" action="orderstoinvoice.php">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="socid" value="' . $socid . '">'; print '<input type="hidden" name="socid" value="' . $socid . '">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&amp;socid=' . $socid, '', $sortfield, $sortorder); print_liste_field_titre('Ref', 'orderstoinvoice.php', 'c.ref', '', '&amp;socid=' . $socid, '', $sortfield, $sortorder);
@ -511,10 +521,12 @@ if (($action != 'create' && $action != 'add') && !$error) {
// Lignes des champs de filtre // Lignes des champs de filtre
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
// REF // REF
print '<input class="flat" size="10" type="text" name="sref" value="' . $sref . '">'; print '<input class="flat" size="10" type="text" name="sref" value="' . $sref . '">';
print '</td>'; print '</td>';
// print '<td class="liste_titre">'; // print '<td class="liste_titre">';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="10" name="sref_client" value="' . $sref_client . '">'; print '<input class="flat" type="text" size="10" name="sref_client" value="' . $sref_client . '">';
@ -604,7 +616,7 @@ if (($action != 'create' && $action != 'add') && !$error) {
print '<input type="hidden" name="action" value="create">'; print '<input type="hidden" name="action" value="create">';
print '<input type="hidden" name="origin" value="order_supplier"><br>'; print '<input type="hidden" name="origin" value="order_supplier"><br>';
// print '<a class="butAction" href="index.php">'.$langs->trans("GoBack").'</a>'; // print '<a class="butAction" href="index.php">'.$langs->trans("GoBack").'</a>';
print '<input type="submit" class="butAction" value="' . $langs->trans("GenerateBill") . '">'; print '<input type="submit" class="butAction" name="createbill" value="' . $langs->trans("GenerateBill") . '">';
print '</div>'; print '</div>';
print '</div>'; print '</div>';

View File

@ -156,3 +156,4 @@ OptionToSetOrderBilledNotEnabled=Option from module Workflow, to set order to 'B
IfValidateInvoiceIsNoOrderStayUnbilled=If invoice validation is 'No', the order will remain to status 'Unbilled' until the invoice is validated. IfValidateInvoiceIsNoOrderStayUnbilled=If invoice validation is 'No', the order will remain to status 'Unbilled' until the invoice is validated.
CloseReceivedSupplierOrdersAutomatically=Close order to status "%s" automatically if all products are received. CloseReceivedSupplierOrdersAutomatically=Close order to status "%s" automatically if all products are received.
SetShippingMode=Set shipping mode SetShippingMode=Set shipping mode
WithReceptionFinished=With reception finished