';
-
- // Ref
- print '| '.$langs->trans('Ref').' | ';
- print '';
- print $html->showrefnav($commande,'ref','',1,'ref','ref');
- print ' | ';
- print '
';
-
- // Ref commande client
- print '| ';
- print '';
- print ' | ';
- if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder')
- {
- print '';
- }
- else
- {
- print $commande->ref_client;
- }
- print ' | ';
- print '
';
-
-
- // Third party
- print '| '.$langs->trans('Company').' | ';
- print ''.$soc->getNomUrl(1,'compta').' | ';
- print '
';
-
- // Discounts for third party
- print '| '.$langs->trans('Discounts').' | ';
- if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
- else print $langs->trans("CompanyHasNoRelativeDiscount");
- print '. ';
- $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
- $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
- $absolute_discount=price2num($absolute_discount,'MT');
- $absolute_creditnote=price2num($absolute_creditnote,'MT');
- if ($absolute_discount)
- {
- if ($commande->statut > 0)
- {
- print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie));
- }
- else
- {
- // Remise dispo de type non avoir
- $filter='fk_facture_source IS NULL';
- print ' ';
- $html->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount,$filter);
- }
- }
- if ($absolute_creditnote)
- {
- print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->monnaie)).'. ';
- }
- if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
- print ' |
';
-
- // Date
- print '| '.$langs->trans('Date').' | ';
- print ''.dol_print_date($commande->date,'daytext').' | ';
- print ''.$langs->trans('Source').' : '.$commande->getLabelSource();
- if ($commande->source == 0 && $conf->propal->enabled && $commande->propale_id)
- {
- // Si source = propal
- $propal = new Propal($db);
- $propal->fetch($commande->propale_id);
- print ' -> '.$propal->ref.'';
- }
- print ' | ';
- print '
';
-
- // Delivery date planed
- print '| ';
- print '';
- print ' | ';
- if ($_GET['action'] == 'editdate_livraison')
- {
- print '';
- }
- else
- {
- print dol_print_date($commande->date_livraison,'daytext');
- }
- print ' | ';
- print ''.$langs->trans('NotePublic').' : ';
- print nl2br($commande->note_public);
- print ' | ';
- print '
';
-
- // Delivery address
- if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS)
- {
- print '| ';
- print '';
- print ' | ';
-
- if ($_GET['action'] == 'editdelivery_adress')
- {
- $html->form_address($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
- }
- else
- {
- $html->form_address($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'none','commande',$commande->id);
- }
- print ' |
';
- }
-
- // Conditions et modes de reglement
- print '| ';
- print '';
- 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 '| ';
- print '';
- 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 ' |
';
-
- // Projet
- if ($conf->projet->enabled)
- {
- $langs->load('projects');
- print '| ';
- print '';
- print ' | ';
- if ($_GET['action'] == 'classer')
- {
- $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'projectid');
- }
- else
- {
- $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'none');
- }
- print ' |
';
- }
-
- // Lignes de 3 colonnes
-
- // Total HT
- print '| '.$langs->trans('AmountHT').' | ';
- print ''.price($commande->total_ht).' | ';
- print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
-
- // Total TVA
- print '| '.$langs->trans('AmountVAT').' | '.price($commande->total_tva).' | ';
- print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
-
- // Amount Local Taxes
- if ($mysoc->pays_code=='ES')
- {
- if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
- {
- print '| '.$langs->transcountry("AmountLT1",$mysoc->pays_code).' | ';
- print ''.price($commande->total_localtax1).' | ';
- print ''.$langs->trans("Currency".$conf->monnaie).' |
';
- }
- if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
- {
- print '| '.$langs->transcountry("AmountLT2",$mysoc->pays_code).' | ';
- print ''.price($commande->total_localtax2).' | ';
- print ''.$langs->trans("Currency".$conf->monnaie).' |
';
- }
- }
-
- // Total TTC
- print '| '.$langs->trans('AmountTTC').' | '.price($commande->total_ttc).' | ';
- print ''.$langs->trans('Currency'.$conf->monnaie).' |
';
-
- // Statut
- print '| '.$langs->trans('Status').' | ';
- print ''.$commande->getLibStatut(4).' | ';
- print '
';
-
- print '
';
-
- /*
- * Lines
- */
- $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, l.fk_remise_except, l.remise_percent, l.subprice,';
- $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
- $sql.= ' l.date_start,';
- $sql.= ' l.date_end,';
- $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
- $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.rang, l.rowid";
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0; $total = 0;
-
- if ($num) print '';
- if ($num)
- {
- print '';
- print '| '.$langs->trans('Description').' | ';
- print ''.$langs->trans('VAT').' | ';
- print ''.$langs->trans('PriceUHT').' | ';
- print ''.$langs->trans('Qty').' | ';
- print ''.$langs->trans('ReductionShort').' | ';
- print ''.$langs->trans('TotalHTShort').' | ';
- print ' | ';
- print "
\n";
- }
-
- $var=true;
- while ($i < $num)
- {
- $objp = $db->fetch_object($resql);
- $var=!$var;
-
- // Show product and description
- $type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
- // Try to enhance type detection using date_start and date_end for free lines where type
- // was not saved.
- if (! empty($objp->date_start)) $type=1;
- if (! empty($objp->date_end)) $type=1;
-
- print '';
- if ($objp->fk_product > 0)
- {
- print '';
- print ''; // ancre pour retourner sur la ligne
-
- // Show product and description
- $product_static->type=$objp->fk_product_type;
- $product_static->id=$objp->fk_product;
- $product_static->ref=$objp->ref;
- $product_static->libelle=$objp->product_label;
- $text=$product_static->getNomUrl(1);
- $text.= ' - '.$objp->product_label;
- $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
- print $html->textwithtooltip($text,$description,3,'','',$i);
-
- // Show range
- print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
-
- // Add description in form
- if ($conf->global->PRODUIT_DESC_IN_FORM)
- {
- print ($objp->description && $objp->description!=$objp->product_label)?' '.dol_htmlentitiesbr($objp->description):'';
- }
-
- print ' | ';
- }
- else
- {
- print '';
- if (($objp->info_bits & 2) == 2)
- {
- print '';
- print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
- print '';
- if ($objp->description)
- {
- if ($objp->description == '(CREDIT_NOTE)')
- {
- require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
- $discount=new DiscountAbsolute($db);
- $discount->fetch($objp->fk_remise_except);
- print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
- }
- else
- {
- print ' - '.nl2br($objp->description);
- }
- }
- }
- else
- {
- if ($type==1) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
- print $text.' '.nl2br($objp->description);
-
- // Show range
- print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
- }
- print " | \n";
- }
- print ''.vatrate($objp->tva_tx).'% | ';
-
- print ''.price($objp->subprice)." | \n";
-
- print '';
- if (($objp->info_bits & 2) != 2)
- {
- print $objp->qty;
- }
- else print ' ';
- print ' | ';
-
- if ($objp->remise_percent > 0)
- {
- print ''.$objp->remise_percent."% | \n";
- }
- else
- {
- print ' | ';
- }
-
- print ''.price($objp->total_ht)." | \n";
-
- print ' | ';
- print '
';
-
- $total = $total + ($objp->qty * $objp->price);
- $i++;
- }
- $db->free($resql);
- }
- else
- {
- dol_print_error($db);
- }
-
- print '
';
-
- print '';
-
-
- /*
- * Boutons actions
- */
-
- if (! $user->societe_id && ! $commande->facturee)
- {
- print "