* Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2006 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /** \file htdocs/commande/fiche.php \ingroup commande \brief Fiche commande \version $Revision$ */ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); $langs->load('orders'); $langs->load('sendings'); $langs->load('companies'); $langs->load('bills'); $langs->load('propal'); $user->getrights('commande'); $user->getrights('expedition'); if (!$user->rights->commande->lire) accessforbidden(); if ($conf->projet->enabled) { require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); } require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); // Sécurité accés client $socidp=0; if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } /* * Actions */ // Categorisation dans projet if ($_POST['action'] == 'classin' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $commande->classin($_POST['projetid']); } // Ajout commande if ($_POST['action'] == 'add' && $user->rights->commande->creer) { $datecommande = mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $commande = new Commande($db); $commande->soc_id = $_POST['soc_id']; $commande->date_commande = $datecommande; $commande->note = $_POST['note']; $commande->source = $_POST['source_id']; $commande->projetid = $_POST['projetid']; $commande->remise_percent = $_POST['remise_percent']; $commande->ref_client = $_POST['ref_client']; $commande->modelpdf = $_POST['model']; $commande->cond_reglement_id = $_POST['cond_reglement_id']; $commande->mode_reglement_id = $_POST['mode_reglement_id']; $commande->date_livraison = $_POST['liv_year']."-".$_POST['liv_month']."-".$_POST['liv_day']; $commande->add_product($_POST['idprod1'],$_POST['qty1'],$_POST['remise_percent1']); $commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']); $commande->add_product($_POST['idprod3'],$_POST['qty3'],$_POST['remise_percent3']); $commande->add_product($_POST['idprod4'],$_POST['qty4'],$_POST['remise_percent4']); $commande->add_product($_POST['idprod5'],$_POST['qty5'],$_POST['remise_percent5']); $commande->add_product($_POST['idprod6'],$_POST['qty6'],$_POST['remise_percent6']); $commande->add_product($_POST['idprod7'],$_POST['qty7'],$_POST['remise_percent7']); $commande->add_product($_POST['idprod8'],$_POST['qty8'],$_POST['remise_percent8']); $commande_id = $commande->create($user); $_GET['id'] = $commande->id; $action = ''; } // Positionne ref commande client if ($_POST['action'] == 'set_ref_client' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $commande->set_ref_client($user, $_POST['ref_client']); } if ($_POST['action'] == 'setremise' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $commande->set_remise($user, $_POST['remise']); } if ($_POST['action'] == 'setnote' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $commande->set_note($user, $_POST['note']); } if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $commande->set_date_livraison($user,$_POST['liv_year']."-".$_POST['liv_month']."-".$_POST['liv_day']); } if ($_POST['action'] == 'setmode' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $result=$commande->mode_reglement($_POST['mode_reglement_id']); if ($result < 0) dolibarr_print_error($db,$commande->error); } if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $result=$commande->cond_reglement($_POST['cond_reglement_id']); if ($result < 0) dolibarr_print_error($db,$commande->error); } if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) { /* * Ajout d'une ligne produit dans la commande */ if ($_POST['qty'] && (($_POST['pu'] && $_POST['desc']) || $_POST['p_idprod'])) { $commande = new Commande($db); $ret=$commande->fetch($_POST['id']); if (isset($_POST['p_idprod'])) { $result = $commande->addline( $_POST['np_desc'], $_POST['product_desc'], $_POST['pu'], $_POST['qty'], $_POST['tva_tx'], $_POST['p_idprod'], $_POST['remise_percent']); } else { $result = $commande->addline_libre( $_POST['desc'], $_POST['pu'], $_POST['qty'], $_POST['tva_tx'], 0, $_POST['remise_percent']); } } } if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save')) { $commande = new Commande($db,'',$_POST['id']); if (! $commande->fetch($_POST['id']) > 0) dolibarr_print_error($db); $result = $commande->update_line($_POST['elrowid'], $_POST['eldesc'], $_POST['elprice'], $_POST['elqty'], $_POST['elremise_percent'], $_POST['eltva_tx'] ); $_GET['id']=$_POST['id']; // Pour réaffichage de la fiche en cours d'édition } if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel')) { Header('Location: fiche.php?id='.$_POST['id']); // Pour réaffichage de la fiche en cours d'édition exit; } if ($_GET['action'] == 'deleteline' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $result = $commande->delete_line($_GET['lineid']); Header('Location: fiche.php?id='.$_GET['id']); } if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->commande->valider) { $commande = new Commande($db); $commande->fetch($_GET['id']); $soc = new Societe($db); $soc->fetch($commande->soc_id); $result = $commande->valid($user); } if ($_POST['action'] == 'confirm_close' && $_POST['confirm'] == 'yes' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($_GET['id']); $result = $commande->cloture($user); } if ($_POST['action'] == 'confirm_cancel' && $_POST['confirm'] == 'yes' && $user->rights->commande->valider) { $commande = new Commande($db); $commande->fetch($_GET['id']); $result = $commande->cancel($user); } if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') { if ($user->rights->commande->supprimer ) { $commande = new Commande($db); $commande->id = $_GET['id']; $commande->delete(); Header('Location: index.php'); } } if ($_POST['action'] == 'builddoc') { /* * Generation de la commande * définit dans /includes/modules/commande/modules_commande.php */ commande_pdf_create($db, $_GET['id'],$_POST['model']); } if($_GET['action'] == 'builddoc') { $commande = new Commande($db); $commande->fetch($_GET['id']); commande_pdf_create($db, $_GET['id'],$commande->modelpdf); } llxHeader('',$langs->trans('OrderCard'),'Commande'); $html = new Form($db); /********************************************************************* * * Mode creation * *********************************************************************/ if ($_GET['action'] == 'create' && $user->rights->commande->creer) { print_titre($langs->trans('CreateOrder')); $new_commande = new Commande($db); if ($propalid) { $sql = 'SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.remise_percent, p.tva, p.total, p.ref, p.fk_cond_reglement, p.fk_mode_reglement, '.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c'; $sql .= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id'; $sql .= ' AND p.rowid = '.$propalid; } else { $sql = 'SELECT s.nom, s.prefix_comm, s.idp, s.mode_reglement, s.cond_reglement '; $sql .= 'FROM '.MAIN_DB_PREFIX.'societe as s '; $sql .= 'WHERE s.idp = '.$_GET['socidp']; } $resql = $db->query($sql); if ( $resql ) { $num = $db->num_rows($resql); if ($num) { $obj = $db->fetch_object($resql); $soc = new Societe($db); $soc->fetch($obj->idp); $nbrow=8; if ($conf->projet->enabled) $nbrow++; print '
'; print ''; print '' ."\n"; print ''; print ''; print ''; // Reference print ''; print ''; // Reference client print ''; print ''; print ''; // Client print ''; print ''; print ''; // date de livraison print ""; // Conditions de réglement print ''; // Mode de réglement print ''; if ($conf->projet->enabled) { print ''; } print ''; print ''; print '"; if ($propalid > 0) { $amount = ($obj->price); print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''; print ''; print ''; print ''; print ''; } else { /* * Services/produits prédéfinis */ $NBLINES=8; print ''; } /* * */ print ''; print ''; print '
'.$langs->trans('Ref').'Provisoire'.$langs->trans('Comments').'
'.$langs->trans('RefCustomer').''; print '
'.$langs->trans('Customer').''.$soc->nom_url.'
'.$langs->trans('Date').''; $html->select_date('','re','','','',"crea_commande"); print '
".$langs->trans("DateDelivery").""; if(DATE_LIVRAISON_WEEK_DELAY != "") { $tmpdte = time() + ((7*DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); $smonth = date("m", $tmpdte); $sday = date("d", $tmpdte); $html->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"crea_commande"); } else $html->select_date('','liv_','','','',"crea_commande"); print "
'.$langs->trans('PaymentConditions').''; $html->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); print '
'.$langs->trans('PaymentMode').''; $html->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); print '
'.$langs->trans('Project').''; $html->select_projects($soc->id,'','projetid'); print '
'.$langs->trans('Source').''; $html->select_array('source_id',$new_commande->sources,2); print '
Modèle'; // pdf include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php'); $form=new Form($db); $model=new ModelePDFCommandes(); $liste=$model->liste_modeles($db); $form->select_array("model",$liste,$conf->global->COMMANDE_ADDON_PDF); print "
'.$langs->trans('Ref').''.$obj->ref.'
'.$langs->trans('TotalTTC').''.price($amount).'
'.$langs->trans('VAT').''.price($obj->tva).'
'.$langs->trans('TotalTTC').''.price($obj->total).'
'; print ''; print ''; for ($i = 1 ; $i <= $NBLINES ; $i++) { print ''; print ''; print ''; } print '
'.$langs->trans('ProductsAndServices').''.$langs->trans('Qty').''.$langs->trans('Discount').'
'; // multiprix if($conf->global->PRODUIT_MULTIPRICES == 1) print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size,$soc->price_level); else print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size); print '%
'; print '
'; if ($propalid) { /* * Produits */ print_titre($langs->trans('Products')); print ''; print ''; print ''; $var=false; $sql = 'SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent'; $sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt, '.MAIN_DB_PREFIX.'product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = '.$propalid; $sql .= ' ORDER BY pt.rowid ASC'; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print ''; print ''; print ''; print ''; print ''; $i++; } } $sql = 'SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent'; $sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt WHERE pt.fk_propal = '.$propalid.' AND pt.fk_product = 0'; $sql .= ' ORDER BY pt.rowid ASC'; if ($db->query($sql)) { $num = $db->num_rows(); $i = 0; while ($i < $num) { $objp = $db->fetch_object(); $var=!$var; print ''; print ''; print ''; print ''; print ''; $i++; } } else { dolibarr_print_error($db); } print '
'.$langs->trans('Ref').''.$langs->trans('Product').''.$langs->trans('Price').''.$langs->trans('Discount').''.$langs->trans('Qty').'
['.$objp->ref.']'.img_object($langs->trans('ShowProduct'),'product').' '.$objp->product.''.price($objp->price).''.$objp->remise_percent.'%'.$objp->qty.'
 '.img_object($langs->trans('ShowProduct'),'product').' '.$objp->product.''.price($objp->price).''.$objp->remise_percent.'%'.$objp->qty.'
'; } } } else { dolibarr_print_error($db); } } else /* *************************************************************************** */ /* */ /* Mode vue et edition */ /* */ /* *************************************************************************** */ { $id = $_GET['id']; if ($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(); $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'); $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++; } if ($conf->compta->enabled) { $head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id; $head[$h][1] = $langs->trans('ComptaCard'); $h++; } if ($conf->use_preview_tabs) { $head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id; $head[$h][1] = $langs->trans("Preview"); $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); /* * Confirmation de la suppression de la commande */ if ($_GET['action'] == 'delete') { $html->form_confirm('fiche.php?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete'); print '
'; } /* * Confirmation de la validation */ if ($_GET['action'] == 'valid') { //$numfa = commande_get_num($soc); $html->form_confirm('fiche.php?id='.$id, $langs->trans('ValidateOrder'), $langs->trans('ConfirmValidateOrder'), 'confirm_valid'); print '
'; } /* * Confirmation de la cloture */ if ($_GET['action'] == 'cloture') { //$numfa = commande_get_num($soc); $html->form_confirm('fiche.php?id='.$id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close'); print '
'; } /* * Confirmation de l'annulation */ if ($_GET['action'] == 'annuler') { $html->form_confirm('fiche.php?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel'); print '
'; } /* * Commande */ $nbrow=8; if ($conf->projet->enabled) $nbrow++; print ''; // Ref print ''; print ''; print ''; // Ref commande client print ''; print ''; print ''; // Société print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // date de livraison print ''; // Conditions et modes de réglement print ''; print ''; // Projet if ($conf->projet->enabled) { $langs->load('projects'); print ''; } // Lignes de 3 colonnes print ''; if ($user->rights->commande->creer && $_GET['action'] == 'setdiscount') { print ''; } else { print ''; } print ''; // Total HT print ''; print ''; print ''; // Total TVA print ''; print ''; // Total TTC print ''; print ''; print '
'.$langs->trans('Ref').''.$commande->ref.''.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ; if ($commande->source == 0) { // Si source = propal $propal = new Propal($db); $propal->fetch($commande->propale_id); print ' -> '.$propal->ref.''; } print '
'; print ''; if ($_GET['action'] != 'refcdeclient') print ''; print '
'; print $langs->trans('RefCustomer').''; print ''.img_edit($langs->trans('Edit')).'
'; print '
'; if ($user->rights->commande->creer && $_GET['action'] == 'refcdeclient') { print '
'; print ''; print ''; print ' '; print '
'; } else { print $commande->ref_client; } print '
'.$langs->trans('Note').' :
'; if ($commande->brouillon == 1 && $user->rights->commande->creer) { print '
'; print ''; print '
'; print '
'; print '
'; } else { print nl2br($commande->note); } print '
'.$langs->trans('Customer').''; print ''.$soc->nom.'
'.$langs->trans('Status').''.$commande->statuts[$commande->statut].'
'.$langs->trans('Date').''.dolibarr_print_date($commande->date,'%A %d %B %Y').'
'; print ''; if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; print '
'; print $langs->trans('DateDelivery'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print '
'; if ($_GET['action'] == 'editdate_livraison') { print '
'; print ''; $html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison"); print ''; print '
'; } else { print dolibarr_print_date($commande->date_livraison,'%a %d %B %Y'); } print '
'; print ''; if ($_GET['action'] != 'editconditions' && $commande->brouillon) print ''; print '
'; print $langs->trans('PaymentConditions'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print '
'; if ($_GET['action'] == 'editconditions') { $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'cond_reglement_id'); } else { $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'none'); } print '
'; print ''; if ($_GET['action'] != 'editmode' && $commande->brouillon) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; print '
'; if ($_GET['action'] == 'editmode') { $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'mode_reglement_id'); } else { $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none'); } print '
'; print ''; if ($_GET['action'] != 'classer') print ''; print '
'; print $langs->trans('Project'); print ''.img_edit($langs->trans('SetProject')).'
'; print '
'; if ($_GET['action'] == 'classer') { $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'projetid'); } else { $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'none'); } print '
'; print ''; if ($_GET['action'] != 'setdiscount' && $commande->brouillon) print ''; print '
'; print $langs->trans('GlobalDiscount').''; print ''.img_edit($langs->trans('Edit')).'
'; print '
'; print '
'; print ''; print '%'; print '
'; print ''; print ''.$commande->remise_percent.'%
'.$langs->trans('TotalHT').''.price($commande->total_ht).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('TotalVAT').''.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'; if ($conf->global->COM_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC) { $sql.= ', p.description as product_desc'; } $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 ''; } $var=true; while ($i < $num) { $objp = $db->fetch_object($resql); $var=!$var; // Ligne en mode visu if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid) { print ''; if ($objp->fk_product > 0) { print ''; } else { print ''; } print ''; print ''; print ''; if ($objp->remise_percent > 0) { print ''; } else { print ''; } print ''; // Icone d'edition et suppression if ($commande->statut == 0 && $user->rights->commande->creer && $_GET['action'] == '') { print ''; print ''; } else { print ''; } print ''; } // Ligne en mode update if ($_GET['action'] == 'editline' && $user->rights->commande->creer && $_GET['rowid'] == $objp->rowid) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } $total = $total + ($objp->qty * $objp->price); $i++; } $db->free($resql); } else { dolibarr_print_error($db); } /* * Ajouter une ligne */ if ($commande->statut == 0 && $user->rights->commande->creer && ($_GET['action'] == '' || $_GET['action'] == 'builddoc')) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Ajout produit produits/services personalisés print ''; print ''; print ''; $var=true; print ''; print ' '; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Ajout de produits/services prédéfinis print ''; print ''; print ''; $var=!$var; 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)?'
'.stripslashes(nl2br($objp->description)):''; if ($conf->global->COM_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC) { print '
'.nl2br(stripslashes($objp->product_desc)); } 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).''; print img_edit(); print ''; print img_delete(); 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.''; print ' - '.stripslashes(nl2br($objp->product)); print '
'; } print '
'; if($soc->tva_assuj == "0") print '0'; else print $html->select_tva('eltva_tx',$objp->tva_tx,$mysoc,$soc); print '%'; print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').'   
'; if($soc->tva_assuj == "0") print '0'; else print $html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc); print '%
'; // multiprix if($conf->global->PRODUIT_MULTIPRICES == 1) $html->select_produits('','p_idprod','',$conf->produit->limit_size,$soc->price_level); else $html->select_produits('','p_idprod','',$conf->produit->limit_size); print '
'; print ''; print '
 %
'; print ''; /* * Boutons actions */ if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET['action'] == '' || $_GET['action'] == 'builddoc')) { print '
'; if ($conf->expedition->enabled && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer) { print ''.$langs->trans('Send').''; } if ($commande->statut == 0) { if ($user->rights->commande->valider) { print ''.$langs->trans('Valid').''; } } if ($commande->statut == 1 || $commande->statut == 2) { if ($user->rights->commande->creer) { print ''.$langs->trans('Close').''; } } if ($commande->statut == 0 && $user->rights->commande->supprimer) { print ''.$langs->trans('Delete').''; } if ($commande->statut == 1) { $nb_expedition = $commande->nb_expedition(); if ($user->rights->commande->valider && $nb_expedition == 0) { print ''.$langs->trans('CancelOrder').''; } } // Build PDF if ($user->rights->commande->creer) { print ''.$langs->trans("BuildPDF").''; } print '
'; } print '
'; print '
'; /* * Documents générés * */ $comref = sanitize_string($commande->ref); $comref = str_replace("(","",$comref); $comref = str_replace(")","",$comref); $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; $relativepath = $comref.'/'.$comref.'.pdf'; $filedir = $conf->commande->dir_output . '/' . $comref; $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; $genallowed=$user->rights->commande->creer; $delallowed=$user->rights->commande->supprimer; $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)).'
'; print '
'; } */ //$html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); $html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); /* * 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_titre($langs->trans('RelatedBills')); $i = 0; $total = 0; print ''; print '"; print ''; print ''; print ''; $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 ''; $var=True; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print ''; print ''; print ''; $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 { /* Commande non trouvée */ print 'Commande inexistante ou accés refusé'; } } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>