New: Suite gestion de la remise fixe sur propale, commande et facture. Il reste a grer la dcrmentation sur validation de facture.
This commit is contained in:
parent
c1231d322d
commit
bbb34dfd76
@ -171,28 +171,31 @@ if ($_POST['action'] == 'add')
|
||||
// Si on a selectionné une propal à copier, on réalise la copie
|
||||
if($_POST['createmode']=='copy' && $_POST['copie_propal'])
|
||||
{
|
||||
if ($propal->load_from($_POST['copie_propal']) == -1)
|
||||
if ($propal->fetch($_POST['copie_propal']) > 0)
|
||||
{
|
||||
$propal->datep = mktime(12, 1, 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||
$propal->date_livraison = mktime(12, 1, 1, $_POST['liv_month']."-".$_POST['liv_day']."-".$_POST['liv_year']);
|
||||
$propal->adresse_livraison_id = $_POST['adresse_livraison_id'];
|
||||
$propal->duree_validite = $_POST['duree_validite'];
|
||||
$propal->cond_reglement_id = $_POST['cond_reglement_id'];
|
||||
$propal->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
$propal->remise_percent = $_POST['remise_percent'];
|
||||
$propal->remise_absolue = $_POST['remise_absolue'];
|
||||
$propal->socidp = $_POST['socidp'];
|
||||
$propal->contactid = $_POST['contactidp'];
|
||||
$propal->projetidp = $_POST['projetidp'];
|
||||
$propal->modelpdf = $_POST['modelpdf'];
|
||||
$propal->author = $user->id;
|
||||
$propal->note = $_POST['note'];
|
||||
$propal->ref = $_POST['ref'];
|
||||
$propal->statut = 0;
|
||||
|
||||
$id = $propal->create_from();
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = '<div class="error">'.$langs->trans("ErrorFailedToCopyProposal",$_POST['copie_propal']).'</div>';
|
||||
}
|
||||
$propal->datep = mktime(12, 1, 1, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||
$propal->date_livraison = mktime(12, 1, 1, $_POST['liv_month']."-".$_POST['liv_day']."-".$_POST['liv_year']);
|
||||
$propal->adresse_livraison_id = $_POST['adresse_livraison_id'];
|
||||
$propal->duree_validite = $_POST['duree_validite'];
|
||||
$propal->cond_reglement_id = $_POST['cond_reglement_id'];
|
||||
$propal->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
$propal->remise_percent = $_POST['remise_percent'];
|
||||
$propal->remise_absolue = $_POST['remise_absolue'];
|
||||
$propal->socidp = $_POST['socidp'];
|
||||
$propal->contactid = $_POST['contactidp'];
|
||||
$propal->projetidp = $_POST['projetidp'];
|
||||
$propal->modelpdf = $_POST['modelpdf'];
|
||||
$propal->author = $user->id;
|
||||
$propal->note = $_POST['note'];
|
||||
$propal->ref = $_POST['ref'];
|
||||
$propal->statut = 0;
|
||||
|
||||
$id = $propal->create_from();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -641,7 +644,7 @@ if ($_GET['action'] == 'down' && $user->rights->propale->creer)
|
||||
|
||||
|
||||
|
||||
llxHeader();
|
||||
llxHeader('',$langs->trans('Proposal'),'Proposition');
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
@ -744,9 +747,15 @@ if ($_GET['propalid'] > 0)
|
||||
print '. ';
|
||||
if ($absolute_discount)
|
||||
{
|
||||
print '<br>';
|
||||
//print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?propalid='.$propal->id,0,'remise_id',$societe->id,$absolute_discount);
|
||||
if ($propal->statut > 0)
|
||||
{
|
||||
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<br>';
|
||||
print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?propalid='.$propal->id,0,'remise_id',$societe->id,$absolute_discount);
|
||||
}
|
||||
}
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
|
||||
print '</td></tr>';
|
||||
@ -1004,11 +1013,10 @@ if ($_GET['propalid'] > 0)
|
||||
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a>';
|
||||
print ' - '.nl2br(stripslashes($objp->product));
|
||||
|
||||
print ' - '.nl2br($objp->product);
|
||||
if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
print '<br>'.nl2br(stripslashes($objp->product_desc));
|
||||
print '<br>'.nl2br($objp->product_desc);
|
||||
}
|
||||
|
||||
if ($objp->date_start && $objp->date_end)
|
||||
@ -1029,34 +1037,40 @@ if ($_GET['propalid'] > 0)
|
||||
else
|
||||
{
|
||||
print '<td>';
|
||||
if ($objp->info_bits == 2)
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socidp.'">';
|
||||
print $langs->trans("Discount");
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ': '.nl2br($objp->description);
|
||||
}
|
||||
else
|
||||
{
|
||||
print nl2br($objp->description);
|
||||
}
|
||||
if ($objp->date_start && $objp->date_end)
|
||||
{
|
||||
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
|
||||
}
|
||||
if ($objp->date_start && ! $objp->date_end)
|
||||
{
|
||||
print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
|
||||
}
|
||||
if (! $objp->date_start && $objp->date_end)
|
||||
{
|
||||
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
|
||||
if ($objp->date_start && $objp->date_end)
|
||||
{
|
||||
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
|
||||
}
|
||||
if ($objp->date_start && ! $objp->date_end)
|
||||
{
|
||||
print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
|
||||
}
|
||||
if (! $objp->date_start && $objp->date_end)
|
||||
{
|
||||
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
|
||||
}
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print $objp->qty;
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
if ($objp->remise_percent > 0)
|
||||
{
|
||||
print '<td align="right">'.$objp->remise_percent."%</td>\n";
|
||||
@ -1121,19 +1135,31 @@ if ($_GET['propalid'] > 0)
|
||||
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a>';
|
||||
print ' - '.stripslashes(nl2br($objp->product));
|
||||
print ' - '.nl2br($objp->product);
|
||||
print '<br>';
|
||||
}
|
||||
print '<textarea name="desc" cols="50" rows="'.ROWS_2.'">'.stripslashes($objp->description).'</textarea></td>';
|
||||
print '<textarea name="desc" cols="50" class="flat" rows="'.ROWS_2.'">'.$objp->description.'</textarea></td>';
|
||||
print '<td align="right">';
|
||||
if($societe->tva_assuj == "0")
|
||||
print '<input type="hidden" name="tva_tx" value="0">0';
|
||||
else
|
||||
print $html->select_tva("tva_tx",$objp->tva_tx,$mysoc,$societe);
|
||||
print '</td>';
|
||||
print '<td align="right"><input size="6" type="text" name="subprice" value="'.price($objp->subprice).'"></td>';
|
||||
print '<td align="right"><input size="2" type="text" name="qty" value="'.$objp->qty.'"></td>';
|
||||
print '<td align="right" nowrap><input size="1" type="text" name="remise_percent" value="'.$objp->remise_percent.'">%</td>';
|
||||
print '<td align="right"><input size="6" type="text" class="flat" name="subprice" value="'.price($objp->subprice).'"></td>';
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print '<input size="2" type="text" class="flat" name="qty" value="'.$objp->qty.'">';
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="right" nowrap>';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print '<input size="1" type="text" class="flat" name="remise_percent" value="'.$objp->remise_percent.'">%';
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||
print '</tr>' . "\n";
|
||||
@ -1436,7 +1462,7 @@ if ($_GET['propalid'] > 0)
|
||||
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
|
||||
if (file_exists($file))
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=presend">'.$langs->trans('Send').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=presend">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,22 +516,6 @@ class Commande extends CommonObject
|
||||
$price = $pu - $remise;
|
||||
}
|
||||
|
||||
// Récupère rang max de la commande dans $rangmax
|
||||
$sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.'commandedet';
|
||||
$sql.= ' WHERE fk_commande ='.$commandeid;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$rangmax = $row[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Insertion ligne
|
||||
$ligne=new CommandeLigne($this->db);
|
||||
|
||||
@ -545,7 +529,7 @@ class Commande extends CommonObject
|
||||
$ligne->remise_percent=$remise_percent;
|
||||
$ligne->subprice=$subprice;
|
||||
$ligne->remise=$remise;
|
||||
$ligne->rang=($rangmax+1);
|
||||
$ligne->rang=-1;
|
||||
$ligne->info_bits=$info_bits;
|
||||
$ligne->total_ht=$total_ht;
|
||||
$ligne->total_tva=$total_tva;
|
||||
@ -882,6 +866,73 @@ class Commande extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Ajout d'une ligne remise fixe dans la commande, en base
|
||||
* \param idremise Id de la remise fixe
|
||||
* \return int >0 si ok, <0 si ko
|
||||
*/
|
||||
function insert_discount($idremise)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$remise=new DiscountAbsolute($this->db);
|
||||
$result=$remise->fetch($idremise);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$comligne=new CommandeLigne($this->db);
|
||||
$comligne->fk_commande=$this->id;
|
||||
$comligne->fk_remise_except=$remise->id;
|
||||
$comligne->desc=$remise->description; // Description ligne
|
||||
$comligne->tva_tx=$remise->tva_tx;
|
||||
$comligne->subprice=-$remise->amount_ht;
|
||||
$comligne->price=-$remise->amount_ht;
|
||||
$comligne->fk_product=0; // Id produit prédéfini
|
||||
$comligne->qty=1;
|
||||
$comligne->remise=0;
|
||||
$comligne->remise_percent=0;
|
||||
$comligne->rang=-1;
|
||||
$comligne->info_bits=2;
|
||||
|
||||
$tabprice=calcul_price_total($comligne->qty, $comligne->subprice, 0,$comligne->tva_tx);
|
||||
$comligne->total_ht = $tabprice[0];
|
||||
$comligne->total_tva = $tabprice[1];
|
||||
$comligne->total_ttc = $tabprice[2];
|
||||
|
||||
$result=$comligne->insert();
|
||||
if ($result > 0)
|
||||
{
|
||||
$result=$this->update_price($this->id);
|
||||
if ($result > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$comligne->error;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
@ -2027,8 +2078,29 @@ class CommandeLigne
|
||||
*/
|
||||
function insert()
|
||||
{
|
||||
dolibarr_syslog("CommandeLigne.class::insert rang=".$this->rang);
|
||||
$this->db->begin();
|
||||
|
||||
$rangtouse=$this->rang;
|
||||
if ($rangtouse == -1)
|
||||
{
|
||||
// Récupère rang max de la commande dans $rangmax
|
||||
$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'commandedet';
|
||||
$sql.= ' WHERE fk_commande ='.$this->fk_commande;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$rangtouse = $obj->max + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Insertion dans base de la ligne
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
|
||||
$sql.= ' (fk_commande, label, description, price, qty, tva_tx,';
|
||||
@ -2048,7 +2120,7 @@ class CommandeLigne
|
||||
$sql.= " '".price2num($this->remise)."',";
|
||||
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
|
||||
else $sql.= 'null,';
|
||||
$sql.= ' '.$this->rang.',';
|
||||
$sql.= ' '.$rangtouse.',';
|
||||
if (isset($this->coef)) $sql.= ' '.$this->coef.',';
|
||||
else $sql.= ' null,';
|
||||
$sql.= " '".$this->info_bits."',";
|
||||
|
||||
@ -105,7 +105,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
||||
$commande->contactid = $_POST['contactidp'];
|
||||
|
||||
$commande->fetch_client();
|
||||
|
||||
|
||||
$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']);
|
||||
@ -161,6 +161,24 @@ if ($_POST['action'] == 'setremise' && $user->rights->commande->creer)
|
||||
$commande->set_remise($user, $_POST['remise']);
|
||||
}
|
||||
|
||||
if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
|
||||
{
|
||||
if ($_POST["remise_id"])
|
||||
{
|
||||
$com = new Commande($db);
|
||||
$com->id=$_GET['id'];
|
||||
$ret=$com->fetch($_GET['id']);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$com->insert_discount($_POST["remise_id"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db,$com->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer)
|
||||
{
|
||||
$datelivraison=@mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
|
||||
@ -223,7 +241,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||
$ret=$commande->fetch($_POST['id']);
|
||||
$soc = new Societe($db, $commande->socidp);
|
||||
$soc->fetch($commande->socidp);
|
||||
|
||||
|
||||
if ($ret < 0)
|
||||
{
|
||||
dolibarr_print_error($db,$commande->error);
|
||||
@ -237,9 +255,9 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||
{
|
||||
$prod = new Product($db, $_POST['idprod']);
|
||||
$prod->fetch($_POST['idprod']);
|
||||
|
||||
|
||||
$libelle = $prod->libelle;
|
||||
|
||||
|
||||
// multiprix
|
||||
if ($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||
{
|
||||
@ -249,7 +267,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||
{
|
||||
$pu=$prod->price;
|
||||
}
|
||||
|
||||
|
||||
// La description de la ligne est celle saisie ou
|
||||
// celle du produit si (non saisi + PRODUIT_CHANGE_PROD_DESC défini)
|
||||
$desc=$_POST['np_desc'];
|
||||
@ -257,7 +275,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||
{
|
||||
$desc = $prod->description;
|
||||
}
|
||||
|
||||
|
||||
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
||||
}
|
||||
else
|
||||
@ -266,7 +284,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||
$tva_tx=$_POST['tva_tx'];
|
||||
$desc=$_POST['desc'];
|
||||
}
|
||||
|
||||
|
||||
$commande->addline(
|
||||
$_POST['id'],
|
||||
$libelle,
|
||||
@ -317,7 +335,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
|
||||
dolibarr_print_error($db,$commande->error);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$_GET['id']=$_POST['id']; // Pour réaffichage de la fiche en cours d'édition
|
||||
}
|
||||
|
||||
@ -395,7 +413,7 @@ if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
||||
if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
||||
{
|
||||
/*
|
||||
* Repasse la commande en mode brouillon
|
||||
@ -446,7 +464,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||
{
|
||||
dolibarr_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Efface les fichiers
|
||||
@ -497,25 +515,25 @@ if ($_POST['action'] == 'send')
|
||||
$message = $_POST['message'];
|
||||
$sendtocc = $_POST['sendtocc'];
|
||||
$deliveryreceipt = $_POST['deliveryreceipt'];
|
||||
|
||||
|
||||
if ($_POST['action'] == 'send')
|
||||
{
|
||||
$subject = $_POST['subject'];
|
||||
|
||||
|
||||
if($subject == '')
|
||||
{
|
||||
$subject = $langs->trans('Order').' '.$commande->ref;
|
||||
}
|
||||
|
||||
|
||||
$actiontypeid=8;
|
||||
$actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'.<br>';
|
||||
|
||||
|
||||
if ($message)
|
||||
{
|
||||
$actionmsg.='Texte utilisé dans le corps du message:<br>';
|
||||
$actionmsg.=$message;
|
||||
}
|
||||
|
||||
|
||||
$actionmsg2='Envoi commande par mail';
|
||||
}
|
||||
|
||||
@ -580,7 +598,7 @@ if ($_POST['action'] == 'send')
|
||||
}
|
||||
|
||||
|
||||
llxHeader('',$langs->trans('OrderCard'),'Commande');
|
||||
llxHeader('',$langs->trans('Order'),'Commande');
|
||||
|
||||
|
||||
$html = new Form($db);
|
||||
@ -663,7 +681,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||
print '.';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans('Date').'</td><td>';
|
||||
$html->select_date('','re','','','',"crea_commande");
|
||||
@ -948,7 +966,7 @@ else
|
||||
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel');
|
||||
print '<br />';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression d'une ligne produit
|
||||
*/
|
||||
@ -1001,14 +1019,24 @@ else
|
||||
print '</tr>';
|
||||
|
||||
// Ligne info remises tiers
|
||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||
$absolute_discount=$soc->getCurrentDiscount();
|
||||
print '. ';
|
||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||
print '.';
|
||||
if ($absolute_discount)
|
||||
{
|
||||
if ($commande->statut > 0)
|
||||
{
|
||||
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<br>';
|
||||
print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount);
|
||||
}
|
||||
}
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
|
||||
print '</td></tr>';
|
||||
|
||||
// Date
|
||||
@ -1133,16 +1161,16 @@ else
|
||||
// Lignes de 3 colonnes
|
||||
|
||||
// Total HT
|
||||
print '<tr><td>'.$langs->trans('TotalHT').'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Total TVA
|
||||
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Total TTC
|
||||
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
@ -1154,16 +1182,11 @@ else
|
||||
print "\n";
|
||||
|
||||
/*
|
||||
* 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->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
$sql.= ', p.description as product_desc';
|
||||
}
|
||||
|
||||
* Lignes de commandes
|
||||
*/
|
||||
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, l.info_bits,';
|
||||
$sql.= ' p.label as product, 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;
|
||||
@ -1188,7 +1211,7 @@ else
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
@ -1205,25 +1228,40 @@ else
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
||||
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a> - '.stripslashes(nl2br($objp->product));
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):'';
|
||||
|
||||
print ' '.$objp->ref.'</a> - '.nl2br($objp->product);
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.nl2br($objp->description):'';
|
||||
if ($conf->global->COM_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||
{
|
||||
print '<br>'.nl2br(stripslashes($objp->product_desc));
|
||||
print '<br>'.nl2br($objp->product_desc);
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>'.stripslashes(nl2br($objp->description));
|
||||
print '<td>';
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$commande->socidp.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ': '.nl2br($objp->description);
|
||||
}
|
||||
else
|
||||
{
|
||||
print nl2br($objp->description);
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice).'</td>';
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print $objp->qty;
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
if ($objp->remise_percent > 0)
|
||||
{
|
||||
print '<td align="right">'.$objp->remise_percent.'%</td>';
|
||||
@ -1287,10 +1325,10 @@ else
|
||||
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a>';
|
||||
print ' - '.stripslashes(nl2br($objp->product));
|
||||
print ' - '.nl2br($objp->product);
|
||||
print '<br>';
|
||||
}
|
||||
print '<textarea name="eldesc" cols="50" rows="1">'.stripslashes($objp->description).'</textarea></td>';
|
||||
print '<textarea name="eldesc" class="flat" cols="50" rows="1">'.$objp->description.'</textarea></td>';
|
||||
print '<td align="right">';
|
||||
if($soc->tva_assuj == "0")
|
||||
print '<input type="hidden" name="tva_tx" value="0">0';
|
||||
@ -1298,8 +1336,20 @@ else
|
||||
print $html->select_tva('tva_tx',$objp->tva_tx,$mysoc,$soc);
|
||||
print '</td>';
|
||||
print '<td align="right"><input size="5" type="text" class="flat" name="pu" value="'.price($objp->subprice).'"></td>';
|
||||
print '<td align="right"><input size="2" type="text" class="flat" name="qty" value="'.$objp->qty.'"></td>';
|
||||
print '<td align="right" nowrap="nowrap"><input size="1" type="text" class="flat" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print '<input size="2" type="text" class="flat" name="qty" value="'.$objp->qty.'">';
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="right" nowrap="nowrap">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print '<input size="1" type="text" class="flat" name="elremise_percent" value="'.$objp->remise_percent.'">%';
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="center" colspan="4"><input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
|
||||
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
|
||||
print '</tr>';
|
||||
@ -1544,7 +1594,7 @@ else
|
||||
$file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf';
|
||||
if (file_exists($file))
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=presend">'.$langs->trans('Send').'</a>';
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=presend">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1764,8 +1814,8 @@ else
|
||||
{
|
||||
dolibarr_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print_titre($langs->trans('SendOrderByMail'));
|
||||
|
||||
@ -20,9 +20,9 @@
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\file htdocs/compta/fiche.php
|
||||
\file htdocs/compta/commande/fiche.php
|
||||
\ingroup commande
|
||||
\brief Fiche commande
|
||||
\version $Revision$
|
||||
@ -43,7 +43,7 @@ $user->getrights('commande');
|
||||
if (! $user->rights->commande->lire) accessforbidden();
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
@ -52,9 +52,9 @@ if ($user->societe_id > 0)
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
*/
|
||||
|
||||
if ($_GET["action"] == 'facturee')
|
||||
if ($_GET["action"] == 'facturee')
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET["id"]);
|
||||
@ -73,7 +73,7 @@ $html = new Form($db);
|
||||
/* Mode vue et edition */
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
|
||||
|
||||
if ($_GET["id"] > 0)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
@ -123,7 +123,7 @@ if ($_GET["id"] > 0)
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
// Société
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
@ -136,11 +136,21 @@ if ($_GET["id"] > 0)
|
||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||
$absolute_discount=$soc->getCurrentDiscount();
|
||||
print '. ';
|
||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||
print '.';
|
||||
if ($absolute_discount)
|
||||
{
|
||||
if ($commande->statut > 0)
|
||||
{
|
||||
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<br>';
|
||||
print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount);
|
||||
}
|
||||
}
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans('Date').'</td>';
|
||||
print '<td colspan="2">'.dolibarr_print_date($commande->date,'%A %d %B %Y').'</td>';
|
||||
@ -154,13 +164,13 @@ if ($_GET["id"] > 0)
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Date de livraison
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DateDelivery');
|
||||
print '</td>';
|
||||
|
||||
|
||||
if (1 == 2 && $_GET['action'] != 'editdate_livraison' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$commande->id.'">'.img_edit($langs->trans('SetDateDelivery'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
@ -178,21 +188,21 @@ if ($_GET["id"] > 0)
|
||||
}
|
||||
print '</td>';
|
||||
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
|
||||
print nl2br($commande->note_public);
|
||||
print nl2br($commande->note_public);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
|
||||
// Adresse de livraison
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
|
||||
if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socidp.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
|
||||
|
||||
if ($_GET['action'] == 'editdelivery_adress')
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
|
||||
@ -202,13 +212,13 @@ if ($_GET["id"] > 0)
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Conditions et modes de réglement
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentConditionsShort');
|
||||
print '</td>';
|
||||
|
||||
|
||||
if ($_GET['action'] != 'editconditions' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
@ -263,36 +273,36 @@ if ($_GET["id"] > 0)
|
||||
// Lignes de 3 colonnes
|
||||
|
||||
// Total HT
|
||||
print '<tr><td>'.$langs->trans('TotalHT').'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Total TVA
|
||||
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
|
||||
// Total TTC
|
||||
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans('Status').'</td>';
|
||||
print '<td colspan="2">'.$commande->getLibStatut(4).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
/*
|
||||
* 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.rang";
|
||||
|
||||
/*
|
||||
* Lignes de commandes
|
||||
*/
|
||||
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, l.info_bits,';
|
||||
$sql.= ' p.label as product, 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)
|
||||
{
|
||||
@ -308,8 +318,8 @@ if ($_GET["id"] > 0)
|
||||
print '<td align="right" width="50">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Discount').'</td>';
|
||||
print '<td align="right">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
@ -328,21 +338,38 @@ if ($_GET["id"] > 0)
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
||||
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a> - '.stripslashes(nl2br($objp->product));
|
||||
print ' '.$objp->ref.'</a> - '.nl2br($objp->product);
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):'';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>'.stripslashes(nl2br($objp->description));
|
||||
print '<td>';
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$commande->socidp.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ': '.nl2br($objp->description);
|
||||
}
|
||||
else
|
||||
{
|
||||
print nl2br($objp->description);
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print $objp->qty;
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
if ($objp->remise_percent > 0)
|
||||
{
|
||||
print '<td align="right">'.$objp->remise_percent."%</td>\n";
|
||||
@ -372,7 +399,7 @@ if ($_GET["id"] > 0)
|
||||
/*
|
||||
* Lignes de remise
|
||||
*/
|
||||
|
||||
|
||||
// Réductions relatives (Remises-Ristournes-Rabbais)
|
||||
/* Une réduction doit s'appliquer obligatoirement sur des lignes de factures
|
||||
et non globalement
|
||||
@ -431,7 +458,7 @@ if ($_GET["id"] > 0)
|
||||
print '</form>';
|
||||
*/
|
||||
|
||||
// Réductions (Remises-Ristournes-Rabbais)
|
||||
// Remises absolue
|
||||
/* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées
|
||||
$var=!$var;
|
||||
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
|
||||
@ -110,12 +110,22 @@ if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->facture->creer)
|
||||
$_GET['facid']=$_REQUEST['facid'];
|
||||
}
|
||||
|
||||
if ($_REQUEST['action'] == 'setremiseabsolue' && $user->rights->facture->creer)
|
||||
if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($_REQUEST['facid']);
|
||||
$result = $fac->set_remise_absolue($user, $_POST['remise_absolue']);
|
||||
$_GET['facid']=$_REQUEST['facid'];
|
||||
if ($_POST["remise_id"])
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->id=$_GET['facid'];
|
||||
$ret=$fac->fetch($_GET['facid']);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$fac->insert_discount($_POST["remise_id"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db,$fac->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'classin')
|
||||
@ -1023,11 +1033,13 @@ if ($_GET['action'] == 'create')
|
||||
print '<td> </td>';
|
||||
if ($conf->service->enabled)
|
||||
{
|
||||
print '<td>'.$langs->trans('ServiceLimitedDuration').'</td></tr>';
|
||||
print '<td>'.$langs->trans('ServiceLimitedDuration').'</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
for ($i = 1 ; $i <= $NBLINES ; $i++)
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
// multiprix
|
||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||
$html->select_produits('','idprod'.$i,'',$conf->produit->limit_size,$soc->price_level);
|
||||
@ -1110,10 +1122,12 @@ if ($_GET['action'] == 'create')
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>';
|
||||
|
||||
// Lignes de propal produits prédéfinis
|
||||
$sql = 'SELECT pt.rowid, p.label as product, p.ref, pt.tva_tx, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent, pt.description';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt, '.MAIN_DB_PREFIX.'product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = '.$_GET['propalid'];
|
||||
$sql .= ' ORDER BY pt.rowid ASC';
|
||||
// Lignes de propal
|
||||
$sql = 'SELECT p.label as product, p.ref, p.rowid as prodid,';
|
||||
$sql.= ' pt.rowid, pt.tva_tx, pt.price, pt.qty, pt.remise_percent, pt.description, pt.info_bits';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
|
||||
$sql.= ' WHERE pt.fk_propal = '.$_GET['propalid'];
|
||||
$sql.= ' ORDER BY pt.rowid ASC';
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -1124,16 +1138,30 @@ if ($_GET['action'] == 'create')
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(''),'product').' '.$objp->ref.'</a>';
|
||||
print $objp->product?' - '.$objp->product:'';
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
if ($objp->info_bits == 2)
|
||||
{
|
||||
print img_object($langs->trans(''),'reduc').' '.$langs->trans("Discount");
|
||||
}
|
||||
else if ($objp->prodid)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(''),'product').' '.$objp->ref.'</a>';
|
||||
print $objp->product?' - '.$objp->product:'';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print "</td>\n";
|
||||
print '<td>';
|
||||
print stripslashes(nl2br(dolibarr_trunc($objp->description,60)));
|
||||
print nl2br(dolibarr_trunc($objp->description,60));
|
||||
print '</td>';
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.price($objp->price).'</td>';
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">'.$objp->remise_percent.'%</td>';
|
||||
print '<td align="right">';
|
||||
print $objp->info_bits != 2 ? $objp->remise_percent.'%' : ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
@ -1142,36 +1170,6 @@ if ($_GET['action'] == 'create')
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
// Lignes de propal non produits prédéfinis
|
||||
$sql = 'SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.price, pt.qty, pt.remise_percent';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt ';
|
||||
$sql .= ' WHERE pt.fk_propal = '.$_GET['propalid'];
|
||||
$sql .= ' AND (pt.fk_product = 0 or pt.fk_product is null)';
|
||||
$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 '<tr '.$bc[$var].'><td> </td>';
|
||||
print '<td>'.dolibarr_trunc($objp->product,60).'</td>';
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.price($objp->price).'</td>';
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">'.$objp->remise_percent.'%</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
@ -1190,10 +1188,10 @@ if ($_GET['action'] == 'create')
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>';
|
||||
|
||||
$sql = 'SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description,';
|
||||
$sql = 'SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description, pt.info_bits,';
|
||||
$sql.= ' p.label as product, p.ref, p.rowid as prodid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as pt, '.MAIN_DB_PREFIX.'product as p';
|
||||
$sql.= ' WHERE pt.fk_product = p.rowid AND pt.fk_commande = '.$commande->id;
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
|
||||
$sql.= ' WHERE pt.fk_commande = '.$commande->id;
|
||||
$sql.= ' ORDER BY pt.rowid ASC';
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -1206,16 +1204,30 @@ if ($_GET['action'] == 'create')
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(''),'product').' '.$objp->ref.'</a>';
|
||||
print $objp->product?' - '.$objp->product:'';
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
if ($objp->info_bits == 2)
|
||||
{
|
||||
print img_object($langs->trans(''),'reduc').' '.$langs->trans("Discount");
|
||||
}
|
||||
else if ($objp->prodid)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(''),'product').' '.$objp->ref.'</a>';
|
||||
print $objp->product?' - '.$objp->product:'';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print "</td>\n";
|
||||
print '<td>';
|
||||
print stripslashes(nl2br(dolibarr_trunc($objp->description,60)));
|
||||
print nl2br(dolibarr_trunc($objp->description,60));
|
||||
print '</td>';
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice).'</td>';
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">'.$objp->remise_percent.'%</td>';
|
||||
print '<td align="right">';
|
||||
print $objp->info_bits != 2 ? $objp->remise_percent.'%' : ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
@ -1224,37 +1236,6 @@ if ($_GET['action'] == 'create')
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
// Lignes de commande non produits prédéfinis
|
||||
$sql = 'SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.subprice, pt.qty, pt.remise_percent';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'commandedet as pt';
|
||||
$sql .= ' WHERE pt.fk_commande = '.$commande->id;
|
||||
$sql .= ' AND (pt.fk_product = 0 or pt.fk_product is null)';
|
||||
$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 '<tr '.$bc[$var].'><td> </td>';
|
||||
print '<td>'.dolibarr_trunc($objp->product,60).'</td>';
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice).'</td>';
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">'.$objp->remise_percent.'%</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
@ -1274,12 +1255,12 @@ if ($_GET['action'] == 'create')
|
||||
print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>';
|
||||
|
||||
// Lignes de contrat produits prédéfinis
|
||||
$sql = 'SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description,';
|
||||
$sql = 'SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description, pt.info_bits,';
|
||||
$sql.= ' pt.date_ouverture_prevue as date_debut_prevue, pt.date_ouverture as date_debut_reel,';
|
||||
$sql.= ' pt.date_fin_validite as date_fin_prevue, pt.date_cloture as date_fin_reel,';
|
||||
$sql.= ' p.label as product, p.ref, p.rowid as prodid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'contratdet as pt, '.MAIN_DB_PREFIX.'product as p';
|
||||
$sql.= ' WHERE pt.fk_product = p.rowid AND pt.fk_contrat = '.$contrat->id;
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'contratdet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
|
||||
$sql.= ' WHERE pt.fk_contrat = '.$contrat->id;
|
||||
$sql.= ' ORDER BY pt.rowid ASC';
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -1292,15 +1273,26 @@ if ($_GET['action'] == 'create')
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(''),'service').' '.$objp->ref.'</a>';
|
||||
print $objp->product?' - '.$objp->product:'';
|
||||
// Plage de dates
|
||||
$date_start=$objp->date_debut_prevue;
|
||||
if ($objp->date_debut_reel) $date_start=$objp->date_debut_reel;
|
||||
$date_end=$objp->date_fin_prevue;
|
||||
if ($objp->date_fin_reel) $date_end=$objp->date_fin_reel;
|
||||
print_date_range($date_start,$date_end);
|
||||
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
if ($objp->info_bits == 2)
|
||||
{
|
||||
print img_object($langs->trans(''),'reduc').' '.$langs->trans("Discount");
|
||||
}
|
||||
else if ($objp->prodid)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(''),'service').' '.$objp->ref.'</a>';
|
||||
print $objp->product?' - '.$objp->product:'';
|
||||
// Plage de dates
|
||||
$date_start=$objp->date_debut_prevue;
|
||||
if ($objp->date_debut_reel) $date_start=$objp->date_debut_reel;
|
||||
$date_end=$objp->date_fin_prevue;
|
||||
if ($objp->date_fin_reel) $date_end=$objp->date_fin_reel;
|
||||
print_date_range($date_start,$date_end);
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print "</td>\n";
|
||||
print '<td>';
|
||||
print dolibarr_trunc($objp->description,60);
|
||||
@ -1308,39 +1300,9 @@ if ($_GET['action'] == 'create')
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice).'</td>';
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">'.$objp->remise_percent.'%</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
// Lignes de contrat non produits prédéfinis
|
||||
$sql = 'SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.subprice, pt.qty, pt.remise_percent,';
|
||||
$sql.= ' pt.date_ouverture_prevue as date_debut_prevue, pt.date_ouverture as date_debut_reel,';
|
||||
$sql.= ' pt.date_fin_validite as date_fin_prevue, pt.date_cloture as date_fin_reel';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'contratdet as pt';
|
||||
$sql.= ' WHERE pt.fk_contrat = '.$contrat->id;
|
||||
$sql.= ' AND (pt.fk_product = 0 or pt.fk_product is null)';
|
||||
$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 '<tr '.$bc[$var].'><td> </td>';
|
||||
print '<td>'.dolibarr_trunc($objp->product,60).'</td>';
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice).'</td>';
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">'.$objp->remise_percent.'%</td>';
|
||||
print '<td align="right">';
|
||||
print $objp->info_bits != 2 ? $objp->remise_percent.'%' : ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
@ -1436,17 +1398,17 @@ else
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Reference
|
||||
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$fac->ref.'</td></tr>';
|
||||
|
||||
// Ref client
|
||||
// Reference
|
||||
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$fac->ref.'</td></tr>';
|
||||
|
||||
// Ref client
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">';
|
||||
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'refcdeclient' && $fac->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&facid='.$fac->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
print '</td><td colspan="5">';
|
||||
if ($user->rights->facture->creer && $_GET['action'] == 'refcdeclient')
|
||||
{
|
||||
print '<form action="facture.php?facid='.$id.'" method="post">';
|
||||
@ -1468,13 +1430,24 @@ else
|
||||
print '</tr>';
|
||||
|
||||
// Ligne info remises tiers
|
||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
|
||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
|
||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||
$absolute_discount=$soc->getCurrentDiscount();
|
||||
print '. ';
|
||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||
print '.';
|
||||
if ($absolute_discount)
|
||||
{
|
||||
if ($fac->statut > 0)
|
||||
{
|
||||
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<br>';
|
||||
print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$fac->id,0,'remise_id',$soc->id,$absolute_discount);
|
||||
}
|
||||
}
|
||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
|
||||
print '</td></tr>';
|
||||
|
||||
// Dates
|
||||
@ -1686,7 +1659,7 @@ else
|
||||
* Lignes de factures
|
||||
*/
|
||||
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux,';
|
||||
$sql.= ' l.remise_percent, l.subprice,';
|
||||
$sql.= ' l.remise_percent, l.subprice, l.info_bits,';
|
||||
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' p.ref, p.fk_product_type, p.label as product,';
|
||||
@ -1749,13 +1722,30 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>'.stripslashes(nl2br($objp->description));
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print '<td>';
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$fac->socidp.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ': '.nl2br($objp->description);
|
||||
}
|
||||
else
|
||||
{
|
||||
print nl2br($objp->description);
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
print '<td align="right">'.$objp->tva_taux.'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
print '<td align="right">'.$objp->qty.'</td>';
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print $objp->qty;
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
if ($objp->remise_percent > 0)
|
||||
{
|
||||
print '<td align="right">'.$objp->remise_percent."%</td>\n";
|
||||
@ -1819,19 +1809,31 @@ else
|
||||
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a>';
|
||||
print ' - '.stripslashes(nl2br($objp->product));
|
||||
print ' - '.nl2br($objp->product);
|
||||
print '<br>';
|
||||
}
|
||||
print '<textarea name="desc" cols="70" rows="'.ROWS_2.'">'.stripslashes($objp->description).'</textarea></td>';
|
||||
print '<textarea name="desc" class="flat" cols="70" rows="'.ROWS_2.'">'.$objp->description.'</textarea></td>';
|
||||
print '<td align="right">';
|
||||
if(! $soc->tva_assuj)
|
||||
print '<input type="hidden" name="tva_tx" value="0">0';
|
||||
else
|
||||
print $html->select_tva('tva_tx',$objp->tva_taux,$mysoc,$soc);
|
||||
print '</td>';
|
||||
print '<td align="right"><input size="6" type="text" name="price" value="'.price($objp->subprice).'"></td>';
|
||||
print '<td align="right"><input size="2" type="text" name="qty" value="'.$objp->qty.'"></td>';
|
||||
print '<td align="right" nowrap><input size="2" type="text" name="remise_percent" value="'.$objp->remise_percent.'">%</td>';
|
||||
print '<td align="right"><input size="6" type="text" class="flat" name="price" value="'.price($objp->subprice).'"></td>';
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
print '<input size="2" type="text" class="flat" name="qty" value="'.$objp->qty.'">';
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="right" nowrap>';
|
||||
if (($objp->info_bits & 2) != 0)
|
||||
{
|
||||
print '<input size="2" type="text" class="flat" name="remise_percent" value="'.$objp->remise_percent.'">%';
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="center" rowspan="1" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
|
||||
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
|
||||
print '</tr>' . "\n";
|
||||
@ -2111,13 +2113,13 @@ else
|
||||
// Envoyer
|
||||
if ($fac->statut == 1 && $user->rights->facture->envoyer)
|
||||
{
|
||||
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=presend">'.$langs->trans('Send').'</a>';
|
||||
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=presend">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
|
||||
// Envoyer une relance
|
||||
if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->envoyer)
|
||||
{
|
||||
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=prerelance">'.$langs->trans('SendRemind').'</a>';
|
||||
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=prerelance">'.$langs->trans('SendRemindByMail').'</a>';
|
||||
}
|
||||
|
||||
// Emettre paiement
|
||||
|
||||
95
htdocs/discount.class.php
Normal file
95
htdocs/discount.class.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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/discount.class.php
|
||||
\ingroup propal,facture,commande
|
||||
\brief Fichier de la classe de gestion des remises
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\class DiscountAbsolute
|
||||
\brief Classe permettant la gestion des remises fixes
|
||||
*/
|
||||
|
||||
class DiscountAbsolute
|
||||
{
|
||||
var $id;
|
||||
var $db;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler accès base de données
|
||||
*/
|
||||
function DiscountAbsolute($DB)
|
||||
{
|
||||
$this->db = $DB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Charge objet remiset depuis la base
|
||||
* \param rowid id du projet à charger
|
||||
* \return int <0 si ko, =0 si non trouvé, >0 si ok
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT fk_soc, amount_ht, fk_user, fk_facture, description,";
|
||||
$sql.= " ".$this->db->pdate("datec")." as datec";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except";
|
||||
$sql.= " WHERE rowid=".$rowid;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $rowid;
|
||||
$this->fk_soc = $obj->fk_soc;
|
||||
$this->amount_ht = $obj->amount_ht;
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->fk_facture = $obj->fk_facture;
|
||||
$this->description = $obj->description;
|
||||
$this->datec = $obj->datec;
|
||||
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->free($resql);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -278,16 +278,16 @@ if ($_GET["id"] > 0)
|
||||
// Lignes de 3 colonnes
|
||||
|
||||
// Total HT
|
||||
print '<tr><td>'.$langs->trans('TotalHT').'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Total TVA
|
||||
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Total TTC
|
||||
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
|
||||
@ -164,7 +164,7 @@ class Facture extends CommonObject
|
||||
$sql.= ' datef,';
|
||||
$sql.= ' note,';
|
||||
$sql.= ' note_public,';
|
||||
$sql.= ' ref_client,';
|
||||
$sql.= ' ref_client,';
|
||||
$sql.= ' fk_user_author, fk_projet,';
|
||||
$sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf) ';
|
||||
$sql.= " VALUES (";
|
||||
@ -470,6 +470,74 @@ class Facture extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Ajout d'une ligne remise fixe dans la facture, en base
|
||||
* \param idremise Id de la remise fixe
|
||||
* \return int >0 si ok, <0 si ko
|
||||
*/
|
||||
function insert_discount($idremise)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$remise=new DiscountAbsolute($this->db);
|
||||
$result=$remise->fetch($idremise);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$facligne=new FactureLigne($this->db);
|
||||
$facligne->fk_facture=$this->id;
|
||||
$facligne->fk_remise_except=$remise->id;
|
||||
$facligne->desc=$remise->description; // Description ligne
|
||||
$facligne->tva_tx=$remise->tva_tx;
|
||||
$facligne->subprice=-$remise->amount_ht;
|
||||
$facligne->price=-$remise->amount_ht;
|
||||
$facligne->fk_product=0; // Id produit prédéfini
|
||||
$facligne->qty=1;
|
||||
$facligne->remise=0;
|
||||
$facligne->remise_percent=0;
|
||||
$facligne->rang=-1;
|
||||
$facligne->info_bits=2;
|
||||
|
||||
$tabprice=calcul_price_total($facligne->qty, $facligne->subprice, 0,$facligne->tva_tx);
|
||||
$facligne->total_ht = $tabprice[0];
|
||||
$facligne->total_tva = $tabprice[1];
|
||||
$facligne->total_ttc = $tabprice[2];
|
||||
|
||||
$result=$facligne->insert();
|
||||
if ($result > 0)
|
||||
{
|
||||
$result=$this->update_price($this->id);
|
||||
if ($result > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$facligne->error;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Classe la facture dans un projet
|
||||
* \param projid Id du projet dans lequel classer la facture
|
||||
@ -1033,22 +1101,6 @@ class Facture extends CommonObject
|
||||
$price = ($pu - $remise);
|
||||
}
|
||||
|
||||
// Récupère rang max de la facture dans $rangmax
|
||||
$sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.'facturedet';
|
||||
$sql.= ' WHERE fk_facture ='.$facid;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$rangmax = $row[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Insertion ligne
|
||||
$ligne=new FactureLigne($this->db);
|
||||
|
||||
@ -1064,7 +1116,7 @@ class Facture extends CommonObject
|
||||
$ligne->date_start=$date_start;
|
||||
$ligne->date_end=$date_end;
|
||||
$ligne->ventil=$ventil;
|
||||
$ligne->rang=($rangmax+1);
|
||||
$ligne->rang=-1;
|
||||
$ligne->info_bits=$info_bits;
|
||||
$ligne->total_ht=$total_ht;
|
||||
$ligne->total_tva=$total_tva;
|
||||
@ -2191,8 +2243,29 @@ class FactureLigne
|
||||
*/
|
||||
function insert()
|
||||
{
|
||||
dolibarr_syslog("FactureLigne.class::insert rang=".$this->rang);
|
||||
$this->db->begin();
|
||||
|
||||
$rangtouse=$this->rang;
|
||||
if ($rangtouse == -1)
|
||||
{
|
||||
// Récupère rang max de la facture dans $rangmax
|
||||
$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'facturedet';
|
||||
$sql.= ' WHERE fk_facture ='.$this->fk_facture;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$rangtouse = $obj->max + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Insertion dans base de la ligne
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet';
|
||||
$sql.= ' (fk_facture, description, price, qty, tva_taux,';
|
||||
@ -2218,14 +2291,14 @@ class FactureLigne
|
||||
else { $sql.='null,'; }
|
||||
$sql.= ' '.$this->fk_code_ventilation.',';
|
||||
$sql.= ' '.$this->fk_export_compta.',';
|
||||
$sql.= ' '.$this->rang.',';
|
||||
$sql.= ' '.$rangtouse.',';
|
||||
$sql.= " '".$this->info_bits."',";
|
||||
$sql.= " '".price2num($this->total_ht)."',";
|
||||
$sql.= " '".price2num($this->total_tva)."',";
|
||||
$sql.= " '".price2num($this->total_ttc)."'";
|
||||
$sql.= ')';
|
||||
|
||||
dolibarr_syslog("FactureLigne::insert sql=$sql");
|
||||
dolibarr_syslog("FactureLigne.class::insert sql=$sql");
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -34,8 +34,8 @@ AddBill=Add invoice
|
||||
DeleteBill=Delete invoice
|
||||
SearchABill=Search an invoice
|
||||
CancelBill=Cancel an invoice
|
||||
Send=Send
|
||||
SendRemind=Send reminder
|
||||
SendByMail=EMail
|
||||
SendRemindByMail=EMail reminder
|
||||
DoPaiement=Do payment
|
||||
DoPayment=Do payment
|
||||
VAT=VAT
|
||||
|
||||
@ -82,7 +82,7 @@ CustomerRelativeDiscountShort=Relative discount
|
||||
CustomerAbsoluteDiscountShort=Absolute discount
|
||||
CompanyHasRelativeDiscount=This customer has a discount of <b>%s%%</b>
|
||||
CompanyHasNoRelativeDiscount=This customer has no relative discount by default
|
||||
CompanyHasAbsoluteDiscount=This customer has a <b>%s %s</b> discount credit
|
||||
CompanyHasAbsoluteDiscount=This customer still has discount credits for <b>%s %s</b>
|
||||
CompanyHasNoAbsoluteDiscount=This customer has no discount credit available
|
||||
CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users)
|
||||
CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself)
|
||||
|
||||
@ -22,7 +22,7 @@ StatusOrderOnProcessShort=On process
|
||||
StatusOrderProcessedShort=Processed
|
||||
StatusOrderToBillShort=To bill
|
||||
StatusOrderCanceled=Canceld
|
||||
StatusOrderDraft=Draft
|
||||
StatusOrderDraft=Draft (need to be validated)
|
||||
StatusOrderValidated=Validated
|
||||
StatusOrderOnProcess=On process
|
||||
StatusOrderProcessed=Processed
|
||||
@ -71,7 +71,7 @@ RefCustomer=Ref. customer
|
||||
RefCustomerOrder=Ref. customer order
|
||||
CustomerOrder=Customer order
|
||||
RefCustomerOrderShort=Ref. cust. order
|
||||
SendPropalByMail=Send order by mail
|
||||
SendOrderByMail=Send order by mail
|
||||
ActionsOnOrder=Actions on order
|
||||
NoArticleOfTypeProduct=No article of type 'product' so no shippable article for this order
|
||||
OrderMode=Order method
|
||||
|
||||
@ -4,8 +4,8 @@ Bills=Factures
|
||||
ClassifyPayed=Classer 'Payée'
|
||||
ClassifyCanceled=Classer 'Abandonnée'
|
||||
CreateBill=Créer Facture
|
||||
Send=Envoyer
|
||||
SendRemind=Envoyer un rappel
|
||||
SendByMail=Envoyer
|
||||
SendRemindByMail=Envoyer rappel
|
||||
DoPaiement=Emettre un paiement
|
||||
VAT=TVA
|
||||
VATRate=Taux TVA
|
||||
|
||||
@ -34,8 +34,8 @@ AddBill=Cr
|
||||
DeleteBill=Supprimer facture
|
||||
SearchABill=Rechercher une facture
|
||||
CancelBill=Annuler une facture
|
||||
Send=Envoyer
|
||||
SendRemind=Envoyer rappel
|
||||
SendByMail=Envoyer
|
||||
SendRemindByMail=Envoyer rappel
|
||||
DoPaiement=Émettre paiement
|
||||
DoPayment=Émettre paiement
|
||||
VAT=TVA
|
||||
|
||||
@ -22,7 +22,7 @@ StatusOrderOnProcessShort=En cours
|
||||
StatusOrderProcessedShort=Traitée
|
||||
StatusOrderToBillShort=À facturer
|
||||
StatusOrderCanceled=Annulée
|
||||
StatusOrderDraft=Brouillon
|
||||
StatusOrderDraft=Brouillon (à valider)
|
||||
StatusOrderValidated=Validée
|
||||
StatusOrderOnProcess=Traitement en cours
|
||||
StatusOrderProcessed=Traitée
|
||||
|
||||
@ -147,13 +147,9 @@ class Propal extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Ajout d'un produit dans la proposition, en base
|
||||
* \param idproduct Id du produit à ajouter
|
||||
* \param qty Quantité
|
||||
* \param remise_percent Remise relative effectuée sur le produit
|
||||
* \param p_desc Descriptif optionnel
|
||||
* \return int >0 si ok, <0 si ko
|
||||
* \see add_product
|
||||
* \brief Ajout d'une ligne remise fixe dans la proposition, en base
|
||||
* \param idremise Id de la remise fixe
|
||||
* \return int >0 si ok, <0 si ko
|
||||
*/
|
||||
function insert_discount($idremise)
|
||||
{
|
||||
@ -1857,52 +1853,6 @@ class Propal extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge l'objet propal en mémoire avec propal dont l'id est passé en argument
|
||||
* \param $src_propal_id Id de la propal source
|
||||
* \return int >0 si ok, <0 si ko
|
||||
* \see fetch
|
||||
*/
|
||||
function load_from($src_propal_id)
|
||||
{
|
||||
$src_propal = new Propal($this->db);
|
||||
if($src_propal->fetch($src_propal_id) < 0)
|
||||
{
|
||||
dolibarr_syslog("Propal::load_from: Erreur de lecture de la propal source.");
|
||||
return -1;
|
||||
}
|
||||
$this->datep = $src_propal->datep;
|
||||
$this->fin_validite = $src_propal->fin_validite;
|
||||
$this->date = $src_propal->date;
|
||||
$this->ref = $src_propal->ref;
|
||||
$this->price = $src_propal->price;
|
||||
$this->remise = $src_propal->remise;
|
||||
$this->remise_percent = $src_propal->remise_percent;
|
||||
$this->remise_absolue = $src_propal->remise_absolue;
|
||||
$this->total = $src_propal->total;
|
||||
$this->total_ht = $src_propal->total_ht;
|
||||
$this->total_tva = $src_propal->total_tva;
|
||||
$this->total_ttc = $src_propal->total_ttc;
|
||||
$this->socidp = $src_propal->socidp;
|
||||
$this->projetidp = $src_propal->projetidp;
|
||||
$this->contactid = $src_propal->contactid;
|
||||
$this->modelpdf = $src_propal->modelpdf;
|
||||
$this->note = $src_propal->note;
|
||||
$this->note_public = $src_propal->note_public;
|
||||
$this->statut = $src_propal->statut;
|
||||
$this->statut_libelle = $src_propal->statut_libelle;
|
||||
$this->cond_reglement_id = $src_propal->cond_reglement_id;
|
||||
$this->mode_reglement_id = $src_propal->mode_reglement_id;
|
||||
$this->date_livraison = $src_propal->date_livraison;
|
||||
$this->adresse_livraison_id = $src_propal->adresse_livraison_id;
|
||||
$this->user_author_id = $src_propal->user_author_id;
|
||||
|
||||
$this->cond_reglement = $src_propal->cond_reglement;
|
||||
$this->cond_reglement_code=$src_propal->cond_reglement_code;
|
||||
$this->ref_url = $src_propal->ref_url;
|
||||
$this->lignes = $src_propal->lignes;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Insert en base un objet propal complétement définie par ses données membres (resultant d'une copie par exemple).
|
||||
@ -2171,7 +2121,7 @@ class PropaleLigne
|
||||
*/
|
||||
function insert()
|
||||
{
|
||||
dolibarr_syslog("PropaleLigne::insert rang=".$this->rang);
|
||||
dolibarr_syslog("PropaleLigne.class::insert rang=".$this->rang);
|
||||
$this->db->begin();
|
||||
|
||||
$rangtouse=$this->rang;
|
||||
@ -2221,7 +2171,7 @@ class PropaleLigne
|
||||
$sql.= " '".price2num($this->total_ttc)."'";
|
||||
$sql.= ')';
|
||||
|
||||
dolibarr_syslog("PropaleLigne::insert sql=$sql");
|
||||
dolibarr_syslog("PropaleLigne.class::insert sql=$sql");
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
BIN
htdocs/theme/dev/img/object_reduc.png
Normal file
BIN
htdocs/theme/dev/img/object_reduc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1009 B |
BIN
htdocs/theme/dolibarr/img/object_reduc.png
Normal file
BIN
htdocs/theme/dolibarr/img/object_reduc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1009 B |
BIN
htdocs/theme/eldy/img/object_reduc.png
Normal file
BIN
htdocs/theme/eldy/img/object_reduc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1009 B |
BIN
htdocs/theme/freelug/img/object_reduc.png
Normal file
BIN
htdocs/theme/freelug/img/object_reduc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1009 B |
BIN
htdocs/theme/yellow/img/object_reduc.png
Normal file
BIN
htdocs/theme/yellow/img/object_reduc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1009 B |
Loading…
Reference in New Issue
Block a user