diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php index 971676929b5..d6ebed0ca46 100644 --- a/htdocs/compta/commande/fiche.php +++ b/htdocs/compta/commande/fiche.php @@ -77,348 +77,356 @@ $html = new Form($db); if ($_GET["id"] > 0) { - $commande = new Commande($db); - if ( $commande->fetch($_GET["id"]) > 0) - { - $soc = new Societe($db); - $soc->fetch($commande->soc_id); - $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $commande = new Commande($db); + if ( $commande->fetch($_GET["id"]) > 0) + { + $soc = new Societe($db); + $soc->fetch($commande->soc_id); + $author = new User($db); + $author->id = $commande->user_author_id; + $author->fetch(); - $h=0; + $h=0; - if ($conf->commande->enabled && $user->rights->commande->lire) - { - $head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderCard"); - $h++; + if ($conf->commande->enabled && $user->rights->commande->lire) + { + $head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id; + $head[$h][1] = $langs->trans("OrderCard"); + $h++; } - - if ($conf->expedition->enabled && $user->rights->expedition->lire) - { - $head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id; - $head[$h][1] = $langs->trans("SendingCard"); - $h++; - } - if ($conf->compta->enabled) - { - $head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id; - $head[$h][1] = $langs->trans("ComptaCard"); - $hselected = $h; - $h++; + if ($conf->expedition->enabled && $user->rights->expedition->lire) + { + $head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id; + $head[$h][1] = $langs->trans("SendingCard"); + $h++; } - - $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id; - $head[$h][1] = $langs->trans("Info"); - $h++; - dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref"); - - /* - * Commande - */ - print ''; - print '"; - print ''; - print '"; + if ($conf->compta->enabled) + { + $head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id; + $head[$h][1] = $langs->trans("ComptaCard"); + $hselected = $h; + $h++; + } - print ""; - print ''; - print ''; - - print ''; - print "\n"; + $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id; + $head[$h][1] = $langs->trans("Info"); + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref"); + + /* + * Commande + */ + print '
'.$langs->trans("Ref")."'.$commande->ref.''.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ; - if ($commande->source == 0) - { - /* Propale */ - $propal = new Propal($db); - $propal->fetch($commande->propale_id); - print ' -> '.$propal->ref.''; - } - print "
".$langs->trans("Customer")."'; - print ''.$soc->nom.'
'.$langs->trans("Status").'".$commande->statuts[$commande->statut]."
'; + + print '"; + print ''; + print '"; + + // Client + print ""; + print ''; + print ''; + + // Statut + print ''; + print "\n"; $nbrow=6; if ($conf->projet->enabled) $nbrow++; print ''; - print ''; - print "\n"; - print ''; + // Date + print ''; + print "\n"; + print ''; - // Projet - if ($conf->projet->enabled) + // Projet + print ''; + if ($conf->projet->enabled) + { + $langs->load("projects"); + print '"; + } + else + { + print ''; + } + print ''; + + // Lignes de 3 colonnes + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Ref")."'.$commande->ref.''.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ; + if ($commande->source == 0) + { + /* Propale */ + $propal = new Propal($db); + $propal->fetch($commande->propale_id); + print ' -> '.$propal->ref.''; + } + print "
".$langs->trans("Customer")."'; + print ''.$soc->nom.'
'.$langs->trans("Status").'".$commande->statuts[$commande->statut]."'.$langs->trans("Note").' :
'; - if ($commande->brouillon == 1 && $user->rights->commande->creer) + if ($commande->brouillon == 1 && $user->rights->commande->creer) { - print '
'; - print ''; - print '
'; - print '
'; - print '
'; + print '
'; + print ''; + print '
'; + print '
'; + print '
'; } else { - print nl2br($commande->note); + print nl2br($commande->note); } print '
'.$langs->trans("Date").'".dolibarr_print_date($commande->date,"%A %d %B %Y")."
'.$langs->trans("Date").'".dolibarr_print_date($commande->date,"%A %d %B %Y")."
'; + print ''; + //if ($_GET["action"] != "classer") print ''; + print '
'; + print $langs->trans("Project"); + print 'id.'">'.img_edit($langs->trans("SetProject")).'
'; + print '
'; + if ($_GET["action"] == "classer") { - $langs->load("projects"); - print ''; - print ''; - //if ($_GET["action"] != "classer") print ''; - print '
'; - print $langs->trans("Project"); - print 'id.'">'.img_edit($langs->trans("SetProject")).'
'; - print '
'; - if ($_GET["action"] == "classer") + $html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"projetid"); + } + else + { + $html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"none"); + } + print "  
'.$langs->trans("AmountHT").''.price($commande->total_ht).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("GlobalDiscount").''; + print $commande->remise_percent.'% '; + print '
'.$langs->trans("VAT").''.price($commande->total_tva).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("TotalTTC").''.price($commande->total_ttc).''.$langs->trans("Currency".$conf->monnaie).'

'; + + /* + * Lignes de commandes + * + */ + $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,'; + $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; + $sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; + $sql.= " WHERE l.fk_commande = ".$commande->id; + $sql.= " ORDER BY l.rowid"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + + print ''; + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ''; + if ($objp->fk_product > 0) { - $html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"projetid"); + print ''; } else { - $html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"none"); + print '\n"; } - print ""; - } else { - print ''; + print ''; + + print '\n"; + + print ''; + + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + + print '\n"; + + print ''; + print ''; + + $i++; } - - // Lignes de 3 colonnes - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('AmountHT').'  
'; + if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); + else print img_object($langs->trans('ShowProduct'),'product'); + print ' '.$objp->ref.' - '.stripslashes(nl2br($objp->product)); + print ($objp->description && $objp->description!=$objp->product)?'
'.$objp->description:''; + print '
'.stripslashes(nl2br($objp->description)); + print "  '.$objp->tva_tx.'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."  
'.$langs->trans("AmountHT").''.price($commande->total_ht).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("GlobalDiscount").''; - print $commande->remise_percent.'% '; - print '
'.$langs->trans("VAT").''.price($commande->total_tva).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("TotalTTC").''.price($commande->total_ttc).''.$langs->trans("Currency".$conf->monnaie).'

'; - - /* - * Lignes de commandes - * - */ - $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,'; - $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; - $sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; - $sql.= " WHERE l.fk_commande = ".$commande->id; - $sql.= " ORDER BY l.rowid"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; $total = 0; - - print ''; - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('AmountHT').'  
'; - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - - $var=!$var; - print ''; - if ($objp->fk_product > 0) - { - print ''; - if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); - else print img_object($langs->trans('ShowProduct'),'product'); - print ' '.$objp->ref.' - '.stripslashes(nl2br($objp->product)); - print ($objp->description && $objp->description!=$objp->product)?'
'.$objp->description:''; - print ''; - } - else - { - print ''.stripslashes(nl2br($objp->description)); - print "\n"; - } - print ''.$objp->tva_tx.'%'; - - print ''.price($objp->subprice)."\n"; - - print ''.$objp->qty.''; - - if ($objp->remise_percent > 0) - { - print ''.$objp->remise_percent."%\n"; - } - else - { - print ' '; - } - - print ''.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."\n"; - - print '  '; - print ''; - - $i++; - } - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } - print ''; - - print ''; + print ''; /* - * Boutons actions - */ - + * Boutons actions + */ + if (! $user->societe_id && ! $commande->facturee) { print "
\n"; - + if ($commande->statut > 0 && $user->rights->facture->creer) { print ''.$langs->trans("CreateBill").''; } - + if ($user->rights->commande->creer) { print ''.$langs->trans("ClassifyBilled").''; } print '
'; } - - - print "
"; - /* - * Documents générés - * - */ - $file = $conf->facture->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; - $relativepath = $commande->ref."/".$commande->ref.".pdf"; + print "
"; - $var=true; - - if (file_exists($file)) - { - print_titre($langs->trans("Documents")); - print ''; - - print ""; - print ''; - print ''; - print ''; - print ''; - - print "
".$langs->trans("Order")." PDF'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; - } + /* + * Documents générés + * + */ + $file = $conf->facture->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; + $relativepath = $commande->ref."/".$commande->ref.".pdf"; - /* - * Liste des factures - */ - $sql = "SELECT f.rowid,f.facnumber, f.total_ttc, ".$db->pdate("f.datef")." as df"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."co_fa as cf"; - $sql .= " WHERE f.rowid = cf.fk_facture AND cf.fk_commande = ". $commande->id; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - if ($num) - { - print '
'; - print_titre($langs->trans("RelatedBills")); - $i = 0; $total = 0; - print ''; - print '"; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print ''; - print ''; - print ''; - $i++; - } - print "
'.$langs->trans("Ref")."'.$langs->trans("Date").''.$langs->trans("Price").'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.''.dolibarr_print_date($objp->df).''.$objp->total_ttc.'
"; - } - } - else - { - dolibarr_print_error($db); - } + $var=true; - print '
'; - - /* - * Liste des expéditions - */ - $sql = "SELECT e.rowid,e.ref,".$db->pdate("e.date_expedition")." as de"; - $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql .= " WHERE e.fk_commande = ". $commande->id; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - if ($num) + if (file_exists($file)) { - print_titre($langs->trans("Sendings")); - $i = 0; $total = 0; - print ''; - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print ''; - print "\n"; - $i++; - } - print "
".$langs->trans("Sendings")."".$langs->trans("Date")."
'.img_object($langs->trans("ShowSending"),"sending").' '.$objp->ref.'".dolibarr_print_date($objp->de)."
"; + print_titre($langs->trans("Documents")); + print ''; + + print ""; + print ''; + print ''; + print ''; + print ''; + + print "
".$langs->trans("Order")." PDF'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; + } + + /* + * Liste des factures + */ + $sql = "SELECT f.rowid,f.facnumber, f.total_ttc, ".$db->pdate("f.datef")." as df"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."co_fa as cf"; + $sql .= " WHERE f.rowid = cf.fk_facture AND cf.fk_commande = ". $commande->id; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + if ($num) + { + print '
'; + print_titre($langs->trans("RelatedBills")); + $i = 0; $total = 0; + print ''; + print '"; + print ''; + print ''; + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + print ''; + print ''; + print ''; + $i++; + } + print "
'.$langs->trans("Ref")."'.$langs->trans("Date").''.$langs->trans("Price").'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.''.dolibarr_print_date($objp->df).''.$objp->total_ttc.'
"; + } + } + else + { + dolibarr_print_error($db); + } + + print '
'; + + /* + * Liste des expéditions + */ + $sql = "SELECT e.rowid,e.ref,".$db->pdate("e.date_expedition")." as de"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " WHERE e.fk_commande = ". $commande->id; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + if ($num) + { + print_titre($langs->trans("Sendings")); + $i = 0; $total = 0; + print ''; + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + print ''; + print "\n"; + $i++; + } + print "
".$langs->trans("Sendings")."".$langs->trans("Date")."
'.img_object($langs->trans("ShowSending"),"sending").' '.$objp->ref.'".dolibarr_print_date($objp->de)."
"; + } + } + else + { + dolibarr_print_error($db); + } + + print "
"; + } else { - dolibarr_print_error($db); - } - - print "
"; - - } - else - { - // Commande non trouvée - print "Commande inexistante"; + // Commande non trouvée + print "Commande inexistante"; } }