diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index 5efeaad7b04..9416732af77 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -98,7 +98,8 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $companystatic = new Societe($db); -llxHeader(); +$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +llxHeader('',$langs->trans("Orders"),$help_url); $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; $sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee'; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index cae2461a780..b99b92391a9 100755 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -29,10 +29,12 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); -require_once(DOL_DOCUMENT_ROOT ."/commande/class/commande.class.php"); +require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); +require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/report.lib.php"); +if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"); $langs->load('orders'); $langs->load('deliveries'); @@ -73,10 +75,9 @@ if ($action == 'create') } } $now=dol_now(); -$html = new Form($db); -$formfile = new FormFile($db); -$companystatic = new Societe($db); -$htmlother = new FormOther($db); + +$viewstatut=GETPOST('viewstatut'); + /* * Actions @@ -267,30 +268,30 @@ if (($action == 'create' || $action == 'add') && empty($mesgs)) { $fk_parent_line = 0; } - $result = $object->addline( - $id, - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $lines[$i]->rang, - $lines[$i]->special_code, - $object->origin, - $lines[$i]->rowid, - $fk_parent_line - ); + $result = $object->addline( + $id, + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $product_type, + $lines[$i]->rang, + $lines[$i]->special_code, + $object->origin, + $lines[$i]->rowid, + $fk_parent_line + ); if ($result > 0) { $lineid=$result; @@ -342,146 +343,149 @@ if (($action == 'create' || $action == 'add') && empty($mesgs)) $mesgs[]='
'.$object->error.'
'; } } +} - /* - * View - */ - $html = new Form($db); - $htmlother = new FormOther($db); - $formfile = new FormFile($db); - $now=dol_now(); - // Mode creation - if ($action == 'create') +/* + * View + */ + +$html = new Form($db); +$htmlother = new FormOther($db); +$formfile = new FormFile($db); +$companystatic = new Societe($db); + +// Mode creation +if ($action == 'create') +{ + $facturestatic=new Facture($db); + + llxHeader(); + print_fiche_titre($langs->trans('NewBill')); + + $soc = new Societe($db); + if ($socid) $res=$soc->fetch($socid); + if ($res) { - $facturestatic=new Facture($db); + $cond_reglement_id = $soc->cond_reglement_id; + $mode_reglement_id = $soc->mode_reglement_id; + $remise_percent = $soc->remise_percent; + } + $remise_absolue = 0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - llxHeader(); - print_fiche_titre($langs->trans('NewBill')); + $absolute_discount=$soc->getAvailableDiscounts(); + print '
'; + print ''; + print ''; + print '' ."\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + // Ref + print ''; + // Tiers + print ''; + print ''."\n"; + print ''; + // Payment term + print ''; + // Payment mode + print ''; + // Project + if ($conf->projet->enabled) + { + $langs->load('projects'); + print ''; + } + // Modele PDF + print ''; + print '"; - $soc = new Societe($db); - if ($socid) $res=$soc->fetch($socid); - if ($res) + // Public note + print ''; + print ''; + print ''; + // Private note + if (! $user->societe_id) + { print ''; - print ''; + print ''; print ''; - // Private note - if (! $user->societe_id) - { - print ''; - print ''; - print ''; - } - - print '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Customer').''; + print $soc->getNomUrl(1); + print ''; + print '
'.$langs->trans('Type').''; + print ''."\n"; + // Standard invoice + print ''."\n"; + print '
'; + print ''; + print ''; + $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); + print $desc; + print '
'; + // Date invoice + print '
'.$langs->trans('Date').''; + $html->select_date(0,'','','','',"add",1,1); + print '
'.$langs->trans('PaymentConditionsShort').''; + $html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id'); + print '
'.$langs->trans('PaymentMode').''; + $html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); + print '
'.$langs->trans('Project').''; + select_projects($soc->id, $projectid, 'projectid'); + print '
'.$langs->trans('Model').''; + include_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'); + $liste=ModelePDFFactures::liste_modeles($db); + print $html->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF); + print "
'.$langs->trans('NotePublic').''; + print '
'.$langs->trans('NotePublic').''.$langs->trans('NotePrivate').''; - print '
'.$langs->trans('NotePrivate').''; - print '
'; - print ''; - } + print ''; + print ''; + + while ($i < $n) { print ''; - + $i++; } - + print "\n"; // Button "Create Draft" print '
'; print "
\n"; } + //Mode liste -else +if (($action != 'create' && $action != 'add') || ! empty($mesgs)) { llxHeader(); ?> - rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ' WHERE c.fk_soc = s.rowid'; - $sql.= ' AND c.fk_statut in (1, 2) AND c.facture = 0'; + // Which invoice to show + if ($viewstatut <> '') + { + if ($viewstatut < 4 && $viewstatut > -2) + { + $sql.= ' AND c.fk_statut ='.$viewstatut; // brouillon, validee, en cours, annulee + if ($viewstatut == 3) + { + $sql.= ' AND c.facture = 0'; // need to create invoice + } + } + if ($viewstatut == 4) + { + $sql.= ' AND c.facture = 1'; // invoice created + } + if ($viewstatut == -2) // To process + { + //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0'; + $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + } + } $sql.= ' AND s.entity = '.$conf->entity; if ($socid) $sql.= ' AND s.rowid = '.$socid; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -511,18 +535,18 @@ else { $sql.= " AND (c.ref LIKE '%".$db->escape($sall)."%' OR c.note LIKE '%".$db->escape($sall)."%')"; } - + //Date filter if ($date_start && $date_end) $sql.= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; - + if (!empty($sref_client)) { $sql.= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; } $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; $resql = $db->query($sql); - + if ($resql) { if ($socid) @@ -545,7 +569,7 @@ else print '

'; $companystatic->id=$socid; $companystatic->nom=$soc->nom; - + print $companystatic->getNomUrl(1,'customer'); print '

'; print ''; @@ -557,7 +581,7 @@ else print_liste_field_titre($langs->trans('Status'),'','','','','align="right"'); print_liste_field_titre($langs->trans('GenerateBill'),'','','','','align="center"'); print ''; - + // Lignes des champs de filtre print ''; print ''; @@ -569,52 +593,52 @@ else //print ''; - + print ''; + //DATE DELIVERY print ''; - - //SEARCH BUTTON + + //SEARCH BUTTON print ''; - + print ''; print ''; - + print ''; $var=True; $generic_commande = new Commande($db); - + while ($i < $num) { $objp = $db->fetch_object($resql); $var=!$var; print ''; print ''; - + print ''; - + // Order date print ''; - + //Delivery date print ''; - + // Statut print ''; - + // Checkbox print '' ; - + print ''; - + $total = $total + $objp->price; $subtotal = $subtotal + $objp->price; $i++; } print '
'; print ''; print ''; - + //DATE ORDER print ''; print $period; - print ''; print $periodely; print ''; print ''; - + //ALL/NONE print ''; if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; print '
'; - + $generic_commande->id=$objp->rowid; $generic_commande->ref=$objp->ref; - + print ''; print ''; - + print ''; - + print '
'; print $generic_commande->getNomUrl(1,$objp->fk_statut); print ''; if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && $db->jdate($objp->date_valid) < ($now - $conf->commande->client->warning_delay)) print img_picto($langs->trans("Late"),"warning"); print ''; $filename=dol_sanitizeFileName($objp->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); @@ -622,37 +646,37 @@ else $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print '
'; print '
'.$objp->ref_client.''; print dol_print_date($db->jdate($objp->date_commande),'day'); print ''; print dol_print_date($db->jdate($objp->date_livraison),'day'); print ''.$generic_commande->LibStatut($objp->fk_statut,$objp->facturee,5).''; print ''; print '
'; - + /* - * Boutons actions + * Boutons actions */ print '
'; print ''; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 9a51e08ea37..e24124c3239 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -858,8 +858,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $newmenu->add("/commande/liste.php?leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->lire); if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire); if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire); - if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->commande->lire); - if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=3", $langs->trans("StatusOrderToBill"), 2, $user->rights->commande->lire); + if ($leftmenu=="orders" && $conf->expedition->enabled) $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->commande->lire); + if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=".($conf->expedition->enabled?"3":"-2"), $langs->trans("StatusOrderToBill"), 2, $user->rights->commande->lire); if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=4", $langs->trans("StatusOrderProcessed"), 2, $user->rights->commande->lire); if ($leftmenu=="orders") $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->rights->commande->lire); $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->rights->commande->lire); diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 570afcdabfb..cc63582c5ab 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -21,7 +21,7 @@ CustomersOrders=Customer's orders CustomersOrdersRunning=Current customer's orders CustomersOrdersAndOrdersLines=Customer orders and order's lines OrdersToValid=Customer's orders to validate -OrdersToBill=Customer's orders to bill +OrdersToBill=Customer's orders delivered OrdersInProcess=Customer's orders in process OrdersToProcess=Customer's orders to process SuppliersOrdersToProcess=Supplier's orders to process @@ -32,7 +32,7 @@ StatusOrderSentShort=In process StatusOrderSent=Shipment in process StatusOrderOnProcessShort=Reception StatusOrderProcessedShort=Processed -StatusOrderToBillShort=To bill +StatusOrderToBillShort=Delivered StatusOrderApprovedShort=Approved StatusOrderRefusedShort=Refused StatusOrderToProcessShort=To process @@ -43,7 +43,7 @@ StatusOrderDraft=Draft (needs to be validated) StatusOrderValidated=Validated StatusOrderOnProcess=Waiting to receive StatusOrderProcessed=Processed -StatusOrderToBill=To bill +StatusOrderToBill=Delivered StatusOrderApproved=Approved StatusOrderRefused=Refused StatusOrderReceivedPartially=Partially received @@ -51,7 +51,7 @@ StatusOrderReceivedAll=Everything received ShippingExist=A shipment exists DraftOrWaitingApproved=Draft or approved not yet ordered DraftOrWaitingShipped=Draft or validated not yet shipped -MenuOrdersToBill=Orders to bill +MenuOrdersToBill=Orders delivered SearchOrder=Search order Sending=Sending Sendings=Sendings diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index cac2bcc278c..329afb01a8d 100644 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -21,7 +21,7 @@ CustomersOrders=Commandes clients CustomersOrdersRunning=Commandes clients en cours CustomersOrdersAndOrdersLines=Commandes clients et lignes de commandes OrdersToValid=Commandes clients à valider -OrdersToBill=Commandes clients à facturer +OrdersToBill=Commandes clients délivrées OrdersInProcess=Commandes clients en traitement OrdersToProcess=Commandes clients à traiter SuppliersOrdersToProcess=Commandes fournisseurs à traiter @@ -32,7 +32,7 @@ StatusOrderOnProcessShort=Traitement en cours StatusOrderSentShort=Envoi en cours StatusOrderSent=Envoi en cours StatusOrderProcessedShort=Traitée -StatusOrderToBillShort=À facturer +StatusOrderToBillShort=Délivrée StatusOrderApprovedShort=Approuvée StatusOrderRefusedShort=Refusée StatusOrderToProcessShort=A traiter @@ -43,7 +43,7 @@ StatusOrderDraft=Brouillon (à valider) StatusOrderValidated=Validée StatusOrderOnProcess=Attente réception StatusOrderProcessed=Traitée -StatusOrderToBill=À facturer +StatusOrderToBill=Délivrée StatusOrderApproved=Approuvée StatusOrderRefused=Refusée StatusOrderReceivedPartially=Reçu partiellement @@ -52,7 +52,7 @@ ShippingExist=Une expédition existe DraftOrWaitingApproved=Brouillon ou approuvée pas encore commandée DraftOrWaitingShipped=Brouillon ou validée pas encore expédiée SearchOrder=Rechercher une commande -MenuOrdersToBill=Commandes à facturer +MenuOrdersToBill=Commandes délivrées Sending=Expédition Sendings=Expéditions ShipProduct=Expédier produit