Mise a jour des champ total_ht, total_tva et total_ttc au niveau ligne
This commit is contained in:
parent
6d09c5a35e
commit
a53e6f7cfc
@ -212,51 +212,21 @@ if ($_GET["action"] == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Destinataire de la propale
|
* Contact de la propale
|
||||||
*/
|
*/
|
||||||
print "<tr><td>".$langs->trans("Contact")."</td><td colspan=\"2\">\n";
|
print "<tr><td>".$langs->trans("DefaultContact")."</td><td colspan=\"2\">\n";
|
||||||
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email FROM ".MAIN_DB_PREFIX."socpeople as p";
|
$html->select_contacts($soc->id,$setcontact,'contactidp',1);
|
||||||
$sql .= " WHERE p.fk_soc = ".$soc->id;
|
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
|
||||||
{
|
|
||||||
$i = 0 ;
|
|
||||||
$numdest = $db->num_rows();
|
|
||||||
|
|
||||||
if ($numdest==0)
|
|
||||||
{
|
|
||||||
print '<font class="error">Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale</font><br>';
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$soc->id.'&action=create&backtoreferer=1">'.$langs->trans("AddContact").'</a>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<select name=\"contactidp\">\n";
|
|
||||||
|
|
||||||
while ($i < $numdest)
|
|
||||||
{
|
|
||||||
$contact = $db->fetch_object();
|
|
||||||
print '<option value="'.$contact->idp.'"';
|
|
||||||
if ($contact->idp == $setcontact)
|
|
||||||
{
|
|
||||||
print ' selected="true"';
|
|
||||||
}
|
|
||||||
print '>'.$contact->firstname.' '.$contact->name;
|
|
||||||
if ($contact->email) { print ' <'.$contact->email.'>'; }
|
|
||||||
print '</option>';
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
print '</select>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->free();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Model
|
||||||
|
print '<tr>';
|
||||||
|
print '<td>'.$langs->trans("DefaultModel").'</td>';
|
||||||
|
print '<td colspan="2">';
|
||||||
|
$model=new ModelePDFPropales();
|
||||||
|
$liste=$model->liste_modeles($db);
|
||||||
|
$html->select_array("model",$liste,$conf->global->PROPALE_ADDON_PDF);
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
// Projet
|
// Projet
|
||||||
if ($conf->projet->enabled)
|
if ($conf->projet->enabled)
|
||||||
{
|
{
|
||||||
@ -266,20 +236,12 @@ if ($_GET["action"] == 'create')
|
|||||||
$numprojet=$html->select_projects($soc->id,$projetid,'projetidp');
|
$numprojet=$html->select_projects($soc->id,$projetid,'projetidp');
|
||||||
if ($numprojet==0)
|
if ($numprojet==0)
|
||||||
{
|
{
|
||||||
print ' <a href=../projet/fiche.php?socidp='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';
|
print ' <a href="../projet/fiche.php?socidp='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>'.$langs->trans("Model").'</td>';
|
|
||||||
print '<td colspan="2">';
|
|
||||||
$model=new ModelePDFPropales();
|
|
||||||
$liste=$model->liste_modeles($db);
|
|
||||||
$html->select_array("model",$liste,$conf->global->PROPALE_ADDON_PDF);
|
|
||||||
print "</td></tr>";
|
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
@ -324,7 +286,7 @@ if ($_GET["action"] == 'create')
|
|||||||
{
|
{
|
||||||
$lib=$langs->trans("ProductsAndServices");
|
$lib=$langs->trans("ProductsAndServices");
|
||||||
|
|
||||||
print '<table class="border">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$lib.'</td>';
|
print '<td>'.$lib.'</td>';
|
||||||
print '<td>'.$langs->trans("Qty").'</td>';
|
print '<td>'.$langs->trans("Qty").'</td>';
|
||||||
@ -355,16 +317,11 @@ if ($_GET["action"] == 'create')
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
/*
|
|
||||||
* Si il n'y a pas de contact pour la societe on ne permet pas la creation de propale
|
|
||||||
*/
|
|
||||||
if ($numdest > 0)
|
|
||||||
{
|
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
print '<center>';
|
print '<center>';
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">';
|
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">';
|
||||||
print '</center>';
|
print '</center>';
|
||||||
}
|
|
||||||
print "</form>";
|
print "</form>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -152,7 +152,7 @@ if ($_POST['action'] == 'add')
|
|||||||
$propal = new Propal($db, $_POST['socidp']);
|
$propal = new Propal($db, $_POST['socidp']);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Si on seléctionné une propal à copier, on réalise la copie
|
* Si on a selectionné une propal à copier, on réalise la copie
|
||||||
*/
|
*/
|
||||||
if($_POST['createmode']=='copy' && $_POST['copie_propal'])
|
if($_POST['createmode']=='copy' && $_POST['copie_propal'])
|
||||||
{
|
{
|
||||||
@ -535,8 +535,6 @@ $html = new Form($db);
|
|||||||
*/
|
*/
|
||||||
if ($_GET['propalid'] > 0)
|
if ($_GET['propalid'] > 0)
|
||||||
{
|
{
|
||||||
$propalid = $_GET['propalid'];
|
|
||||||
|
|
||||||
if ($msg) print "$msg<br>";
|
if ($msg) print "$msg<br>";
|
||||||
|
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
@ -581,21 +579,6 @@ if ($_GET['propalid'] > 0)
|
|||||||
* Fiche propal
|
* Fiche propal
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref, p.fk_statut, p.fk_cond_reglement, p.fk_mode_reglement, '.$db->pdate('p.datep').' as dp, p.note,';
|
|
||||||
$sql.= ' x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'socpeople as x';
|
|
||||||
$sql.= ' WHERE p.fk_soc = s.idp AND p.fk_soc_contact = x.idp AND p.rowid = '.$propal->id;
|
|
||||||
if ($socidp) $sql .= ' AND s.idp = '.$socidp;
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
if ($db->num_rows($resql))
|
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
|
||||||
|
|
||||||
$societe = new Societe($db);
|
|
||||||
$societe->fetch($obj->idp);
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
@ -612,7 +595,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
if ($user->rights->propale->creer && $_GET['action'] == 'refclient')
|
if ($user->rights->propale->creer && $_GET['action'] == 'refclient')
|
||||||
{
|
{
|
||||||
print '<form action="propal.php?propalid='.$propalid.'" method="post">';
|
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
|
||||||
print '<input type="hidden" name="action" value="set_ref_client">';
|
print '<input type="hidden" name="action" value="set_ref_client">';
|
||||||
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$propal->ref_client.'">';
|
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$propal->ref_client.'">';
|
||||||
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||||
@ -625,7 +608,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
$rowspan=9;
|
$rowspan=8;
|
||||||
|
|
||||||
// Société
|
// Société
|
||||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td>';
|
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td>';
|
||||||
@ -781,6 +764,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Destinataire
|
// Destinataire
|
||||||
|
/* On gère les contacts sur onglet contact
|
||||||
$langs->load('mails');
|
$langs->load('mails');
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||||
@ -799,6 +783,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
*/
|
||||||
|
|
||||||
// Projet
|
// Projet
|
||||||
if ($conf->projet->enabled)
|
if ($conf->projet->enabled)
|
||||||
@ -1251,12 +1236,6 @@ if ($_GET['propalid'] > 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print "\n";
|
print "\n";
|
||||||
@ -1274,6 +1253,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '<tr><td>'.$langs->trans("CloseAs").'</td><td>';
|
print '<tr><td>'.$langs->trans("CloseAs").'</td><td>';
|
||||||
print '<input type="hidden" name="action" value="setstatut">';
|
print '<input type="hidden" name="action" value="setstatut">';
|
||||||
print '<select name="statut">';
|
print '<select name="statut">';
|
||||||
|
print '<option value="0"> </option>';
|
||||||
print '<option value="2">'.$propal->labelstatut[2].'</option>';
|
print '<option value="2">'.$propal->labelstatut[2].'</option>';
|
||||||
print '<option value="3">'.$propal->labelstatut[3].'</option>';
|
print '<option value="3">'.$propal->labelstatut[3].'</option>';
|
||||||
print '</select>';
|
print '</select>';
|
||||||
|
|||||||
@ -2158,20 +2158,21 @@ class Commande
|
|||||||
|
|
||||||
class CommandeLigne
|
class CommandeLigne
|
||||||
{
|
{
|
||||||
// From llx_propaldet
|
// From llx_commandedet
|
||||||
var $qty;
|
var $qty;
|
||||||
var $tva_tx;
|
var $tva_tx;
|
||||||
var $subprice;
|
var $subprice;
|
||||||
var $remise_percent;
|
var $remise_percent;
|
||||||
var $price;
|
var $price;
|
||||||
var $product_id;
|
var $product_id; // Id produit prédéfini
|
||||||
var $desc; // Description ligne
|
var $desc; // Description ligne
|
||||||
var $coef;
|
var $coef;
|
||||||
|
|
||||||
// From llx_product
|
// From llx_product
|
||||||
var $libelle; // Label produit
|
var $libelle; // Label produit
|
||||||
var $product_desc; // Description produit
|
var $product_desc; // Description produit
|
||||||
var $ref;
|
var $ref; // Reference produit
|
||||||
|
|
||||||
function CommandeLigne()
|
function CommandeLigne()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -242,12 +242,11 @@ if ($_POST['action'] == 'add')
|
|||||||
{
|
{
|
||||||
for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++)
|
for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++)
|
||||||
{
|
{
|
||||||
$liblignefac=($prop->lignes[$i]->desc?$prop->lignes[$i]->desc:$prop->lignes[$i]->libelle);
|
$desc=($prop->lignes[$i]->desc?$prop->lignes[$i]->desc:$prop->lignes[$i]->libelle);
|
||||||
|
|
||||||
$result = $facture->addline(
|
$result = $facture->addline(
|
||||||
$facid,
|
$facid,
|
||||||
addslashes($liblignefac),
|
$desc,
|
||||||
$prop->lignes[$i]->desc,
|
|
||||||
$prop->lignes[$i]->subprice,
|
$prop->lignes[$i]->subprice,
|
||||||
$prop->lignes[$i]->qty,
|
$prop->lignes[$i]->qty,
|
||||||
$prop->lignes[$i]->tva_tx,
|
$prop->lignes[$i]->tva_tx,
|
||||||
@ -281,10 +280,11 @@ if ($_POST['action'] == 'add')
|
|||||||
$lines = $comm->fetch_lignes();
|
$lines = $comm->fetch_lignes();
|
||||||
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
||||||
{
|
{
|
||||||
|
$desc=($lignes[$i]->description ? $lignes[$i]->description : $lignes[$i]->libelle);
|
||||||
|
|
||||||
$result = $facture->addline(
|
$result = $facture->addline(
|
||||||
$facid,
|
$facid,
|
||||||
addslashes($lines[$i]->description),
|
$desc,
|
||||||
$lines[$i]->desc,
|
|
||||||
$lines[$i]->subprice,
|
$lines[$i]->subprice,
|
||||||
$lines[$i]->qty,
|
$lines[$i]->qty,
|
||||||
$lines[$i]->tva_tx,
|
$lines[$i]->tva_tx,
|
||||||
@ -319,7 +319,7 @@ if ($_POST['action'] == 'add')
|
|||||||
|
|
||||||
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
for ($i = 0 ; $i < sizeof($lines) ; $i++)
|
||||||
{
|
{
|
||||||
$liblignefac=($contrat->lignes[$i]->desc?$contrat->lignes[$i]->desc:$contrat->lignes[$i]->libelle);
|
$desc=($contrat->lignes[$i]->desc?$contrat->lignes[$i]->desc:$contrat->lignes[$i]->libelle);
|
||||||
|
|
||||||
// Plage de dates
|
// Plage de dates
|
||||||
$date_start=$contrat->lignes[$i]->date_debut_prevue;
|
$date_start=$contrat->lignes[$i]->date_debut_prevue;
|
||||||
@ -329,8 +329,7 @@ if ($_POST['action'] == 'add')
|
|||||||
|
|
||||||
$result = $facture->addline(
|
$result = $facture->addline(
|
||||||
$facid,
|
$facid,
|
||||||
addslashes($liblignefac),
|
$desc,
|
||||||
'',
|
|
||||||
$lines[$i]->subprice,
|
$lines[$i]->subprice,
|
||||||
$lines[$i]->qty,
|
$lines[$i]->qty,
|
||||||
$lines[$i]->tva_tx,
|
$lines[$i]->tva_tx,
|
||||||
@ -367,6 +366,9 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
|
|||||||
{
|
{
|
||||||
$fac = new Facture($db);
|
$fac = new Facture($db);
|
||||||
$fac->fetch($_POST['facid']);
|
$fac->fetch($_POST['facid']);
|
||||||
|
$soc = new Societe($db);
|
||||||
|
$soc->fetch($fac->socidp);
|
||||||
|
|
||||||
$datestart='';
|
$datestart='';
|
||||||
$dateend='';
|
$dateend='';
|
||||||
// Si ajout champ produit libre
|
// Si ajout champ produit libre
|
||||||
@ -393,13 +395,42 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
|
|||||||
$dateend=$_POST['date_end_predefyear'].'-'.$_POST['date_end_predefmonth'].'-'.$_POST['date_end_predefday'];
|
$dateend=$_POST['date_end_predefyear'].'-'.$_POST['date_end_predefmonth'].'-'.$_POST['date_end_predefday'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ecrase $pu par celui du produit
|
||||||
|
// Ecrase $desc par celui du produit
|
||||||
|
// Ecrase $txtva par celui du produit
|
||||||
|
if ($_POST['idprod'])
|
||||||
|
{
|
||||||
|
$prod = new Product($db, $_POST['idprod']);
|
||||||
|
$prod->fetch($_POST['idprod']);
|
||||||
|
// multiprix
|
||||||
|
if ($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
|
{
|
||||||
|
$pu = $prod->multiprices[$soc->price_level];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pu=$prod->price;
|
||||||
|
}
|
||||||
|
$desc=$_POST['desc'];
|
||||||
|
if (! $desc) $desc = $prod->description;
|
||||||
|
if ($conf->global->PRODUIT_CHANGE_PROD_DESC) $prod->description;
|
||||||
|
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pu=$_POST['pu'];
|
||||||
|
$tva_tx=$_POST['tva_tx'];
|
||||||
|
$desc=$_POST['desc'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insere ligne
|
||||||
$result = $fac->addline(
|
$result = $fac->addline(
|
||||||
$_POST['facid'],
|
$_POST['facid'],
|
||||||
$_POST['desc'],
|
$desc,
|
||||||
$_POST['product_desc'],
|
$pu,
|
||||||
$_POST['pu'],
|
|
||||||
$_POST['qty'],
|
$_POST['qty'],
|
||||||
$_POST['tva_tx'],
|
$tva_tx,
|
||||||
$_POST['idprod'],
|
$_POST['idprod'],
|
||||||
$_POST['remise_percent'],
|
$_POST['remise_percent'],
|
||||||
$datestart,
|
$datestart,
|
||||||
@ -1933,7 +1964,7 @@ else
|
|||||||
$html->select_produits('','idprod','',$conf->produit->limit_size,$soc->price_level);
|
$html->select_produits('','idprod','',$conf->produit->limit_size,$soc->price_level);
|
||||||
else
|
else
|
||||||
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
$html->select_produits('','idprod','',$conf->produit->limit_size);
|
||||||
print '<br>';
|
if (! $conf->use_ajax) print '<br>';
|
||||||
print '<textarea name="desc" cols="70" rows="'.ROWS_2.'"></textarea></td>';
|
print '<textarea name="desc" cols="70" rows="'.ROWS_2.'"></textarea></td>';
|
||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
print '<td align="right"><input type="text" name="qty" value="1" size="2"></td>';
|
print '<td align="right"><input type="text" name="qty" value="1" size="2"></td>';
|
||||||
|
|||||||
@ -121,7 +121,10 @@ if ($_GET["propalid"] > 0)
|
|||||||
if ($mesg) print "$mesg<br>";
|
if ($mesg) print "$mesg<br>";
|
||||||
|
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
$propal->fetch($_GET["propalid"]);
|
$propal->fetch($_GET['propalid']);
|
||||||
|
|
||||||
|
$societe = new Societe($db);
|
||||||
|
$societe->fetch($propal->soc_id);
|
||||||
|
|
||||||
$head = propal_prepare_head($propal);
|
$head = propal_prepare_head($propal);
|
||||||
dolibarr_fiche_head($head, 'compta', $langs->trans('Proposal'));
|
dolibarr_fiche_head($head, 'compta', $langs->trans('Proposal'));
|
||||||
@ -131,28 +134,24 @@ if ($_GET["propalid"] > 0)
|
|||||||
* Fiche propal
|
* Fiche propal
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref,'.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst, p.note,';
|
|
||||||
$sql.= ' x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture, p.fk_cond_reglement, p.fk_mode_reglement';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x';
|
|
||||||
$sql.= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id;
|
|
||||||
if ($socidp) $sql .= ' AND s.idp = '.$socidp;
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
if ($db->num_rows($resql))
|
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
|
||||||
|
|
||||||
$societe = new Societe($db);
|
|
||||||
$societe->fetch($obj->idp);
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref_url.'</td></tr>';
|
print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">'.$propal->ref_url.'</td></tr>';
|
||||||
|
|
||||||
$rowspan=9;
|
// Ref client
|
||||||
|
print '<tr><td>';
|
||||||
|
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||||
|
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||||
|
print '</td>';
|
||||||
|
if ($_GET['action'] != 'refclient' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&propalid='.$propal->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
|
||||||
|
print '</tr></table>';
|
||||||
|
print '</td><td colspan="3">';
|
||||||
|
print $propal->ref_client;
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$rowspan=8;
|
||||||
|
|
||||||
// Société
|
// Société
|
||||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';
|
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$societe->getNomUrl(1).'</td></tr>';
|
||||||
@ -232,6 +231,7 @@ if ($_GET["propalid"] > 0)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Destinataire
|
// Destinataire
|
||||||
|
/* Remplacé par contacts de propal
|
||||||
$langs->load('mails');
|
$langs->load('mails');
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans('MailTo').'</td>';
|
print '<td>'.$langs->trans('MailTo').'</td>';
|
||||||
@ -254,6 +254,7 @@ if ($_GET["propalid"] > 0)
|
|||||||
print '<td colspan="3"> </td>';
|
print '<td colspan="3"> </td>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Projet
|
// Projet
|
||||||
if ($conf->projet->enabled)
|
if ($conf->projet->enabled)
|
||||||
@ -536,12 +537,6 @@ if ($_GET["propalid"] > 0)
|
|||||||
*/
|
*/
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
@ -688,7 +683,7 @@ if ($_GET["propalid"] > 0)
|
|||||||
*/
|
*/
|
||||||
$sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ;
|
$sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ;
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
|
||||||
$sql .= ' WHERE a.fk_soc = '.$obj->idp.' AND a.propalrowid = '.$propal->id ;
|
$sql .= ' WHERE a.fk_soc = '.$societe->id.' AND a.propalrowid = '.$propal->id ;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -107,7 +107,7 @@ class Facture
|
|||||||
*/
|
*/
|
||||||
function create($user)
|
function create($user)
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf,$mysoc;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
@ -198,10 +198,7 @@ class Facture
|
|||||||
$res=$prod->fetch($this->products[$i]);
|
$res=$prod->fetch($this->products[$i]);
|
||||||
$soc = new Societe($this->db);
|
$soc = new Societe($this->db);
|
||||||
$soc->fetch($this->socidp);
|
$soc->fetch($this->socidp);
|
||||||
if($soc->tva_assuj == "0")
|
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
||||||
$tva_tx ="0";
|
|
||||||
else
|
|
||||||
$tva_tx=$prod->tva_tx;
|
|
||||||
// multiprix
|
// multiprix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
$price = $prod->multiprices[$soc->price_level];
|
$price = $prod->multiprices[$soc->price_level];
|
||||||
@ -239,8 +236,9 @@ class Facture
|
|||||||
if ($_facrec->lignes[$i]->produit_id)
|
if ($_facrec->lignes[$i]->produit_id)
|
||||||
{
|
{
|
||||||
$prod = new Product($this->db, $_facrec->lignes[$i]->produit_id);
|
$prod = new Product($this->db, $_facrec->lignes[$i]->produit_id);
|
||||||
$prod->fetch($_facrec->lignes[$i]->produit_id);
|
$res=$prod->fetch($_facrec->lignes[$i]->produit_id);
|
||||||
}
|
}
|
||||||
|
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
||||||
|
|
||||||
$result_insert = $this->addline(
|
$result_insert = $this->addline(
|
||||||
$this->id,
|
$this->id,
|
||||||
@ -400,7 +398,7 @@ class Facture
|
|||||||
*/
|
*/
|
||||||
$sql = 'SELECT l.rowid, l.fk_product, l.description, l.price, l.qty, l.tva_taux, l.remise, l.remise_percent, l.subprice,';
|
$sql = 'SELECT l.rowid, l.fk_product, l.description, l.price, l.qty, l.tva_taux, l.remise, l.remise_percent, l.subprice,';
|
||||||
$sql.= ' '.$this->db->pdate('l.date_start').' as date_start,'.$this->db->pdate('l.date_end').' as date_end,';
|
$sql.= ' '.$this->db->pdate('l.date_start').' as date_start,'.$this->db->pdate('l.date_end').' as date_end,';
|
||||||
$sql.= ' l.info_bits, l.total_ht, l.total_ttc,';
|
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
|
||||||
$sql.= ' p.label as label, p.description as product_desc';
|
$sql.= ' p.label as label, p.description as product_desc';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||||
@ -432,6 +430,7 @@ class Facture
|
|||||||
$faclig->date_end = $objp->date_end;
|
$faclig->date_end = $objp->date_end;
|
||||||
$faclig->info_bits = $objp->info_bits;
|
$faclig->info_bits = $objp->info_bits;
|
||||||
$faclig->total_ht = $objp->total_ht;
|
$faclig->total_ht = $objp->total_ht;
|
||||||
|
$faclig->total_tva = $objp->total_tva;
|
||||||
$faclig->total_ttc = $objp->total_ttc;
|
$faclig->total_ttc = $objp->total_ttc;
|
||||||
$this->lignes[$i] = $faclig;
|
$this->lignes[$i] = $faclig;
|
||||||
$i++;
|
$i++;
|
||||||
@ -999,10 +998,9 @@ class Facture
|
|||||||
* \brief Ajoute une ligne de facture (associé à un produit/service prédéfini ou non)
|
* \brief Ajoute une ligne de facture (associé à un produit/service prédéfini ou non)
|
||||||
* \param facid id de la facture
|
* \param facid id de la facture
|
||||||
* \param desc description de la ligne
|
* \param desc description de la ligne
|
||||||
* \param product_desc surcharge description produit
|
|
||||||
* \param pu prix unitaire
|
* \param pu prix unitaire
|
||||||
* \param qty quantit
|
* \param qty quantité
|
||||||
* \param txtva taux de tva
|
* \param txtva taux de tva forcé, sinon -1
|
||||||
* \param fk_product id du produit/service predéfini
|
* \param fk_product id du produit/service predéfini
|
||||||
* \param remise_percent pourcentage de remise de la ligne
|
* \param remise_percent pourcentage de remise de la ligne
|
||||||
* \param datestart date de debut de validité du service
|
* \param datestart date de debut de validité du service
|
||||||
@ -1011,8 +1009,9 @@ class Facture
|
|||||||
* \remarks Les parametres sont deja censé etre juste et avec valeurs finales a l'appel
|
* \remarks Les parametres sont deja censé etre juste et avec valeurs finales a l'appel
|
||||||
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete défini
|
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete défini
|
||||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||||
|
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||||
*/
|
*/
|
||||||
function addline($facid, $desc, $product_desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart='', $dateend='', $ventil = 0)
|
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart='', $dateend='', $ventil = 0)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
dolibarr_syslog("facture.class.php::addline($facid,$desc,$product_desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$datestart,$dateend,$ventil)");
|
dolibarr_syslog("facture.class.php::addline($facid,$desc,$product_desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$datestart,$dateend,$ventil)");
|
||||||
@ -1028,19 +1027,6 @@ class Facture
|
|||||||
if (! $qty) $qty=1;
|
if (! $qty) $qty=1;
|
||||||
if (! $ventil) $ventil=0;
|
if (! $ventil) $ventil=0;
|
||||||
if (! $info_bits) $info_bits=0;
|
if (! $info_bits) $info_bits=0;
|
||||||
if ($fk_product && ! $pu)
|
|
||||||
{
|
|
||||||
$prod = new Product($this->db, $fk_product);
|
|
||||||
$prod->fetch($fk_product);
|
|
||||||
$product_desc = $prod->description;
|
|
||||||
// multiprix
|
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
|
||||||
$pu = $prod->multiprices[$soc->price_level];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$pu=$prod->price;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$pu = price2num($pu);
|
$pu = price2num($pu);
|
||||||
$txtva=price2num($txtva);
|
$txtva=price2num($txtva);
|
||||||
|
|
||||||
@ -1082,34 +1068,15 @@ class Facture
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->global->PRODUIT_CHANGE_PROD_DESC)
|
|
||||||
{
|
|
||||||
if (!$product_desc)
|
|
||||||
{
|
|
||||||
$product_desc = $desc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insertion dans base de la ligne
|
// Insertion dans base de la ligne
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet';
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet';
|
||||||
$sql.= ' (fk_facture, description, price, qty, tva_taux,';
|
$sql.= ' (fk_facture, description, price, qty, tva_taux,';
|
||||||
$sql.= ' fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang,';
|
$sql.= ' fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang,';
|
||||||
$sql.= ' info_bits, total_ht, total_tva, total_ttc)';
|
$sql.= ' info_bits, total_ht, total_tva, total_ttc)';
|
||||||
if ($conf->global->PRODUIT_CHANGE_PROD_DESC)
|
$sql.= " VALUES (".$facid.", '".addslashes($desc)."',";
|
||||||
{
|
|
||||||
$sql.= " VALUES ($facid, '".addslashes($product_desc)."',";
|
|
||||||
$sql.= "'".price2num($price)."',";
|
$sql.= "'".price2num($price)."',";
|
||||||
$sql.= "'".price2num($qty)."',";
|
$sql.= "'".price2num($qty)."',";
|
||||||
$sql.= "'".price2num($txtva)."',";
|
$sql.= "'".price2num($txtva)."',";
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql.= " VALUES ($facid, '".addslashes($desc)."',";
|
|
||||||
$sql.= "'".price2num($price)."',";
|
|
||||||
$sql.= "'".price2num($qty)."',";
|
|
||||||
$sql.= "'".price2num($txtva)."',";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($fk_product) { $sql.= "'$fk_product',"; }
|
if ($fk_product) { $sql.= "'$fk_product',"; }
|
||||||
else { $sql.='0,'; }
|
else { $sql.='0,'; }
|
||||||
$sql.= " '".price2num($remise_percent)."',";
|
$sql.= " '".price2num($remise_percent)."',";
|
||||||
@ -1265,7 +1232,7 @@ class Facture
|
|||||||
$err=0;
|
$err=0;
|
||||||
|
|
||||||
// Lit les lignes detail
|
// Lit les lignes detail
|
||||||
$sql = 'SELECT qty, tva_taux, subprice, remise_percent, price, total_ht, total_ttc';
|
$sql = 'SELECT qty, tva_taux, subprice, remise_percent, price, total_ht, total_tva, total_ttc';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet';
|
||||||
$sql.= ' WHERE fk_facture = '.$facid;
|
$sql.= ' WHERE fk_facture = '.$facid;
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|||||||
@ -89,6 +89,7 @@ Supplier=Supplier
|
|||||||
CompanyList=Companies' list
|
CompanyList=Companies' list
|
||||||
AddContact=Add contact
|
AddContact=Add contact
|
||||||
Contact=Contact
|
Contact=Contact
|
||||||
|
DefaultContact=Default contact
|
||||||
AddCompany=Add company
|
AddCompany=Add company
|
||||||
DeleteACompany=Delete a company
|
DeleteACompany=Delete a company
|
||||||
PersonalInformations=Personal data
|
PersonalInformations=Personal data
|
||||||
|
|||||||
@ -104,6 +104,7 @@ Family=Family
|
|||||||
Description=Description
|
Description=Description
|
||||||
Designation=Description
|
Designation=Description
|
||||||
Model=Model
|
Model=Model
|
||||||
|
DefaultModel=Default model
|
||||||
Action=Action
|
Action=Action
|
||||||
About=About
|
About=About
|
||||||
WelcomeString=<font class="body">We are </font>%s<font class="body">, and you are connected as user</font> %s
|
WelcomeString=<font class="body">We are </font>%s<font class="body">, and you are connected as user</font> %s
|
||||||
|
|||||||
@ -89,6 +89,7 @@ Supplier=Fournisseur
|
|||||||
CompanyList=Liste des sociétés
|
CompanyList=Liste des sociétés
|
||||||
AddContact=Créer contact
|
AddContact=Créer contact
|
||||||
Contact=Contact
|
Contact=Contact
|
||||||
|
DefaultContact=Contact par défaut
|
||||||
AddCompany=Créer société
|
AddCompany=Créer société
|
||||||
DeleteACompany=Supprimer une société
|
DeleteACompany=Supprimer une société
|
||||||
PersonalInformations=Informations personnelles
|
PersonalInformations=Informations personnelles
|
||||||
|
|||||||
@ -104,6 +104,7 @@ Description=Description
|
|||||||
Designation=Désignation
|
Designation=Désignation
|
||||||
Action=Action
|
Action=Action
|
||||||
Model=Modèle
|
Model=Modèle
|
||||||
|
DefaultModel=Modèle par défaut
|
||||||
About=À propos
|
About=À propos
|
||||||
WelcomeString=<font class="body">Nous sommes le</font> %s<font class="body">, et vous êtes connecté(e) en tant que </font> %s
|
WelcomeString=<font class="body">Nous sommes le</font> %s<font class="body">, et vous êtes connecté(e) en tant que </font> %s
|
||||||
Number=Nombre
|
Number=Nombre
|
||||||
|
|||||||
@ -1702,10 +1702,13 @@ function price2num($amount)
|
|||||||
* \param taux_produit Taux par defaut du produit vendu
|
* \param taux_produit Taux par defaut du produit vendu
|
||||||
* \return float Taux de tva de la ligne
|
* \return float Taux de tva de la ligne
|
||||||
*/
|
*/
|
||||||
function get_default_tva($societe_vendeuse='', $societe_acheteuse='', $taux_produit='')
|
function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit)
|
||||||
{
|
{
|
||||||
// Si vendeur non assujeti à TVA
|
dolibarr_syslog("get_default_tva vendeur_assujeti=$societe_vendeuse->tva_assuj pays_vendeur=$societe_vendeuse->pays_id, pays_acheteur=$societe_acheteuse->pays_id, taux_produit=$taux_produit");
|
||||||
if (! $societe_vendeuse->tva_assuj) return 0;
|
|
||||||
|
// Si vendeur non assujeti à TVA (tva_assuj vaut 0/1 ou franchise/reel)
|
||||||
|
if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) return 0;
|
||||||
|
if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') return 0;
|
||||||
|
|
||||||
// Si le (pays vendeur = pays acheteur) alors la TVA par défaut=TVA du produit vendu. Fin de règle.
|
// Si le (pays vendeur = pays acheteur) alors la TVA par défaut=TVA du produit vendu. Fin de règle.
|
||||||
if ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id)
|
if ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id)
|
||||||
|
|||||||
@ -33,22 +33,25 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Permet de calculer les parts total HT, TVA et TTC d'une ligne de
|
\brief Permet de calculer les parts total HT, TVA et TTC d'une ligne de
|
||||||
facture, propale ou autre depuis son prix unitaire, quantité et remise ligne.
|
facture, propale ou autre depuis:
|
||||||
|
Prix unitaire, quantité, remise_percent_ligne, txtva, remise_percent_global.
|
||||||
\param qty
|
\param qty
|
||||||
\param pu
|
\param pu
|
||||||
\param remise_percent
|
\param remise_percent_ligne
|
||||||
\param txtva
|
\param txtva
|
||||||
|
\param remise_percent_global
|
||||||
\return result[0] total_ht
|
\return result[0] total_ht
|
||||||
result[1] total_tva
|
result[1] total_tva
|
||||||
result[2] total_ttc
|
result[2] total_ttc
|
||||||
*/
|
*/
|
||||||
function calcul_price_total($qty, $pu, $remise_percent, $txtva)
|
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $remise_percent_global=0)
|
||||||
{
|
{
|
||||||
$result=array();
|
$result=array();
|
||||||
$tot_sans_remise = $pu * $qty;
|
$tot_sans_remise = $pu * $qty;
|
||||||
$tot_avec_remise = $tot_sans_remise - ($tot_sans_remise * $remise_percent / 100);
|
$tot_avec_remise_ligne = $tot_sans_remise * ( 1 - ($remise_percent_ligne / 100));
|
||||||
|
$tot_avec_remise = $tot_avec_remise_ligne * ( 1 - ($remise_percent_global / 100));
|
||||||
$result[0] = round($tot_avec_remise, 2);
|
$result[0] = round($tot_avec_remise, 2);
|
||||||
$result[2] = round($tot_avec_remise + ($tot_avec_remise * $txtva / 100), 2);
|
$result[2] = round($tot_avec_remise * ( 1 + ($txtva / 100)), 2);
|
||||||
$result[1] = $result[2] - $result[0];
|
$result[1] = $result[2] - $result[0];
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,7 +174,27 @@ $mysoc->nom=$conf->global->MAIN_INFO_SOCIETE_NOM;
|
|||||||
$mysoc->adresse=$conf->global->MAIN_INFO_SOCIETE_ADRESSE;
|
$mysoc->adresse=$conf->global->MAIN_INFO_SOCIETE_ADRESSE;
|
||||||
$mysoc->cp=$conf->global->MAIN_INFO_SOCIETE_CP;
|
$mysoc->cp=$conf->global->MAIN_INFO_SOCIETE_CP;
|
||||||
$mysoc->ville=$conf->global->MAIN_INFO_SOCIETE_VILLE;
|
$mysoc->ville=$conf->global->MAIN_INFO_SOCIETE_VILLE;
|
||||||
|
// Si dans MAIN_INFO_SOCIETE_PAYS on a un id de pays, on recupere code
|
||||||
|
if (is_numeric($conf->global->MAIN_INFO_SOCIETE_PAYS))
|
||||||
|
{
|
||||||
|
$mysoc->pays_id=$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||||
|
$sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays";
|
||||||
|
$sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||||
|
$result=$db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object();
|
||||||
|
$mysoc->pays_code=$obj->code;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Si dans MAIN_INFO_SOCIETE_PAYS on a deja un code, tout est fait
|
||||||
|
else
|
||||||
|
{
|
||||||
$mysoc->pays_code=$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
$mysoc->pays_code=$conf->global->MAIN_INFO_SOCIETE_PAYS;
|
||||||
|
}
|
||||||
$mysoc->tel=$conf->global->MAIN_INFO_SOCIETE_TEL;
|
$mysoc->tel=$conf->global->MAIN_INFO_SOCIETE_TEL;
|
||||||
$mysoc->fax=$conf->global->MAIN_INFO_SOCIETE_FAX;
|
$mysoc->fax=$conf->global->MAIN_INFO_SOCIETE_FAX;
|
||||||
$mysoc->url=$conf->global->MAIN_INFO_SOCIETE_WEB;
|
$mysoc->url=$conf->global->MAIN_INFO_SOCIETE_WEB;
|
||||||
|
|||||||
@ -780,6 +780,7 @@ class Product
|
|||||||
if (! $id && ! $ref)
|
if (! $id && ! $ref)
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans('ErrorWrongParameters');
|
$this->error=$langs->trans('ErrorWrongParameters');
|
||||||
|
dolibarr_error("Product::fetch ".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
@ -55,9 +55,6 @@ class Propal
|
|||||||
var $status;
|
var $status;
|
||||||
var $datep;
|
var $datep;
|
||||||
var $fin_validite;
|
var $fin_validite;
|
||||||
|
|
||||||
var $products;
|
|
||||||
var $products_qty;
|
|
||||||
var $price;
|
var $price;
|
||||||
var $cond_reglement_id;
|
var $cond_reglement_id;
|
||||||
var $cond_reglement_code;
|
var $cond_reglement_code;
|
||||||
@ -72,6 +69,9 @@ class Propal
|
|||||||
var $date_livraison;
|
var $date_livraison;
|
||||||
var $adresse_livraison_id;
|
var $adresse_livraison_id;
|
||||||
|
|
||||||
|
var $products;
|
||||||
|
var $products_qty;
|
||||||
|
|
||||||
var $labelstatut=array();
|
var $labelstatut=array();
|
||||||
var $labelstatut_short=array();
|
var $labelstatut_short=array();
|
||||||
|
|
||||||
@ -125,7 +125,6 @@ class Propal
|
|||||||
* \return void
|
* \return void
|
||||||
* \see insert_product
|
* \see insert_product
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function add_product($idproduct, $qty, $remise_percent=0)
|
function add_product($idproduct, $qty, $remise_percent=0)
|
||||||
{
|
{
|
||||||
if ($idproduct > 0)
|
if ($idproduct > 0)
|
||||||
@ -150,7 +149,7 @@ class Propal
|
|||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
* \see add_product
|
* \see add_product
|
||||||
*/
|
*/
|
||||||
function insert_discount($idproduct, $qty, $remise_percent=0, $p_desc='')
|
function insert_discount($idproduct, $qty, $remise_percent=0, $desc='')
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -161,14 +160,20 @@ class Propal
|
|||||||
* \param idproduct Id du produit à ajouter
|
* \param idproduct Id du produit à ajouter
|
||||||
* \param qty Quantité
|
* \param qty Quantité
|
||||||
* \param remise_percent Remise relative effectuée sur le produit
|
* \param remise_percent Remise relative effectuée sur le produit
|
||||||
* \param p_desc Descriptif optionnel
|
* \param desc Descriptif optionnel
|
||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
* \see add_product
|
* \see add_product
|
||||||
|
* \remarks Les parametres sont deja censé etre juste et avec valeurs finales a l'appel
|
||||||
|
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete défini
|
||||||
|
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||||
|
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||||
*/
|
*/
|
||||||
function insert_product($idproduct, $qty, $remise_percent=0, $p_desc='')
|
function insert_product($idproduct, $qty, $remise_percent=0, $desc='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf,$mysoc;
|
||||||
dolibarr_syslog("propal.class.php::insert_product $idproduct, $qty, $remise_percent, $p_desc");
|
dolibarr_syslog("propal.class.php::insert_product $idproduct, $qty, $remise_percent, $desc");
|
||||||
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
@ -180,12 +185,8 @@ class Propal
|
|||||||
$prod = new Product($this->db, $idproduct);
|
$prod = new Product($this->db, $idproduct);
|
||||||
if ($prod->fetch($idproduct) > 0)
|
if ($prod->fetch($idproduct) > 0)
|
||||||
{
|
{
|
||||||
$p_product_desc = $prod->description;
|
|
||||||
$this->fetch_client();
|
$this->fetch_client();
|
||||||
if($this->client->tva_assuj == "0")
|
|
||||||
$txtva ="0";
|
|
||||||
else
|
|
||||||
$txtva=$prod->tva_tx;
|
|
||||||
// multiprix
|
// multiprix
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES == 1)
|
if ($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
{
|
{
|
||||||
@ -197,27 +198,36 @@ class Propal
|
|||||||
$price = price2num($prod->price);
|
$price = price2num($prod->price);
|
||||||
$subprice = price2num($prod->price);
|
$subprice = price2num($prod->price);
|
||||||
}
|
}
|
||||||
/*
|
$txtva = get_default_tva($mysoc,$this->client,$prod->tva_tx);
|
||||||
|
if (! $desc) $desc = $prod->description;
|
||||||
|
if ($conf->global->PRODUIT_CHANGE_PROD_DESC) $desc=$prod->description;
|
||||||
|
|
||||||
*/
|
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||||
|
// qty, pu, remise_percent et txtva
|
||||||
|
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||||
|
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||||
|
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva);
|
||||||
|
$total_ht = $tabprice[0];
|
||||||
|
$total_tva = $tabprice[1];
|
||||||
|
$total_ttc = $tabprice[2];
|
||||||
|
|
||||||
// Calcul remise et nouveau prix
|
// Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser)
|
||||||
$remise = 0;
|
$remise = 0;
|
||||||
if ($remise_percent > 0)
|
if ($remise_percent > 0)
|
||||||
{
|
{
|
||||||
$remise = round(($prod->price * $remise_percent / 100), 2);
|
$remise = round(($prod->price * $remise_percent / 100), 2);
|
||||||
$price = $prod->price - $remise;
|
$price = $prod->price - $remise;
|
||||||
}
|
}
|
||||||
if ($conf->global->PRODUIT_CHANGE_PROD_DESC)
|
|
||||||
{
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice,";
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
|
$sql.= " total_ht, total_tva, total_ttc)";
|
||||||
$sql .= " (".$this->id.",". $idproduct.",'". $qty."','". price2num($price)."','".$txtva."','".addslashes($p_product_desc)."','".price2num($remise_percent)."','".price2num($subprice)."')";
|
$sql.= " VALUES ";
|
||||||
}
|
$sql.= " (".$this->id.",". $idproduct.",'". $qty."','". price2num($price) ."','".$txtva."','".addslashes($desc?$desc:$prod->label)."','".price2num($remise_percent)."','".price2num($subprice)."',";
|
||||||
else
|
$sql.= " '".price2num($total_ht) ."',";
|
||||||
{
|
$sql.= " '".price2num($total_tva)."',";
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
|
$sql.= " '".price2num($total_ttc)."'";
|
||||||
$sql .= " (".$this->id.",". $idproduct.",'". $qty."','". price2num($price) ."','".$txtva."','".addslashes($p_desc?$p_desc:$prod->label)."','".price2num($remise_percent)."','".price2num($subprice)."')";
|
$sql.= ")";
|
||||||
}
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
@ -226,6 +236,7 @@ class Propal
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
|
dolibarr_syslog("Error sql=$sql, error=".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,36 +256,58 @@ class Propal
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajout d'un produit dans la proposition, en base
|
* \brief Ajout d'un produit dans la proposition, en base
|
||||||
* \param p_desc Descriptif optionnel
|
* \param desc Descriptif optionnel
|
||||||
* \param p_price Prix
|
* \param pu Prix
|
||||||
* \param p_qty Quantité
|
* \param qty Quantité
|
||||||
* \param p_tva_tx Taux tva
|
* \param tva_tx Taux tva
|
||||||
* \param remise_percent Remise effectuée sur le produit
|
* \param remise_percent Remise effectuée sur le produit
|
||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
* \see add_product
|
* \see add_product
|
||||||
|
* \remarks Les parametres sont deja censé etre juste et avec valeurs finales a l'appel
|
||||||
|
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete défini
|
||||||
|
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||||
|
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||||
*/
|
*/
|
||||||
function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx, $remise_percent=0)
|
function insert_product_generic($desc, $pu, $qty, $tva_tx, $remise_percent=0)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("propal.class.php::insert_product_generic $p_desc, $p_price, $p_qty, $p_tva_tx, $remise_percent");
|
global $conf,$mysoc;
|
||||||
|
dolibarr_syslog("propal.class.php::insert_product_generic $desc, $pu, $qty, $tva_tx, $remise_percent");
|
||||||
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
// Nettoyage paramètres
|
// Nettoyage paramètres
|
||||||
$remise_percent=price2num($remise_percent);
|
$remise_percent=price2num($remise_percent);
|
||||||
$p_qty=price2num($p_qty);
|
$qty=price2num($qty);
|
||||||
if (strlen(trim($p_qty))==0) $p_qty=1;
|
if (! $qty) $qty=1;
|
||||||
$p_price = price2num($p_price);
|
$pu = price2num($pu);
|
||||||
|
$tva_tx = price2num($tva_tx);
|
||||||
|
|
||||||
$price = $p_price;
|
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||||
$subprice = $p_price;
|
// qty, pu, remise_percent et txtva
|
||||||
|
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||||
|
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||||
|
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $tva_tx);
|
||||||
|
$total_ht = $tabprice[0];
|
||||||
|
$total_tva = $tabprice[1];
|
||||||
|
$total_ttc = $tabprice[2];
|
||||||
|
|
||||||
|
// Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser)
|
||||||
|
$price = $pu;
|
||||||
|
$subprice = $pu;
|
||||||
if ($remise_percent > 0)
|
if ($remise_percent > 0)
|
||||||
{
|
{
|
||||||
$remise = round(($p_price * $remise_percent / 100), 2);
|
$remise = round(($pu * $remise_percent / 100), 2);
|
||||||
$price = $p_price - $remise;
|
$price = $pu - $remise;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice, total_ht, total_tva, total_ttc)";
|
||||||
$sql .= " (".$this->id.", 0,'". $p_qty."','". price2num($price)."','".$p_tva_tx."','".addslashes($p_desc)."','$remise_percent', '".price2num($subprice)."') ; ";
|
$sql.= " VALUES ";
|
||||||
|
$sql.= " (".$this->id.", 0,'". $qty."','". price2num($price)."','".$tva_tx."','".addslashes($desc)."','$remise_percent', '".price2num($subprice)."',";
|
||||||
|
$sql.= " '".price2num($total_ht) ."',";
|
||||||
|
$sql.= " '".price2num($total_tva)."',";
|
||||||
|
$sql.= " '".price2num($total_ttc)."'";
|
||||||
|
$sql.= ")";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
@ -290,6 +323,8 @@ class Propal
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
dolibarr_syslog("Error sql=$sql, error=".$this->error);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,21 +341,37 @@ class Propal
|
|||||||
* \param desc Description
|
* \param desc Description
|
||||||
* \return int 0 en cas de succès
|
* \return int 0 en cas de succès
|
||||||
*/
|
*/
|
||||||
|
function UpdateLigne($id, $pu, $qty, $remise_percent=0, $tva_tx, $desc='')
|
||||||
function UpdateLigne($id, $subprice, $qty, $remise_percent=0, $tva_tx, $desc='')
|
|
||||||
{
|
{
|
||||||
|
global $conf,$mysoc;
|
||||||
|
dolibarr_syslog("propal.class.php::updateligne $id, $pu, $qty, $remise_percent, $tva_tx, $desc");
|
||||||
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
// Nettoyage paramètres
|
// Nettoyage paramètres
|
||||||
$subprice=price2num($subprice);
|
|
||||||
$price = $subprice;
|
|
||||||
$remise_percent=price2num($remise_percent);
|
$remise_percent=price2num($remise_percent);
|
||||||
|
$qty=price2num($qty);
|
||||||
|
if (! $qty) $qty=1;
|
||||||
|
$pu = price2num($pu);
|
||||||
$tva_tx = price2num($tva_tx);
|
$tva_tx = price2num($tva_tx);
|
||||||
|
|
||||||
|
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||||
|
// qty, pu, remise_percent et txtva
|
||||||
|
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||||
|
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||||
|
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $tva_tx);
|
||||||
|
$total_ht = $tabprice[0];
|
||||||
|
$total_tva = $tabprice[1];
|
||||||
|
$total_ttc = $tabprice[2];
|
||||||
|
|
||||||
|
// Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser)
|
||||||
|
$price = $pu;
|
||||||
|
$subprice = $pu;
|
||||||
if ($remise_percent > 0)
|
if ($remise_percent > 0)
|
||||||
{
|
{
|
||||||
$remise = round(($subprice * $remise_percent / 100), 2);
|
$remise = round(($pu * $remise_percent / 100), 2);
|
||||||
$price = $subprice - $remise;
|
$price = $pu - $remise;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet ";
|
||||||
@ -330,6 +381,9 @@ class Propal
|
|||||||
$sql.= " , subprice='".$subprice."'";
|
$sql.= " , subprice='".$subprice."'";
|
||||||
$sql.= " , tva_tx='".$tva_tx."'";
|
$sql.= " , tva_tx='".$tva_tx."'";
|
||||||
$sql.= " , description='".addslashes($desc)."'";
|
$sql.= " , description='".addslashes($desc)."'";
|
||||||
|
$sql.= " , total_ht='".price2num($total_ht)."'";
|
||||||
|
$sql.= " , total_tva='".price2num($total_tva)."'";
|
||||||
|
$sql.= " , total_ttc='".price2num($total_ttc)."'";
|
||||||
$sql.= " WHERE rowid = '".$id."';";
|
$sql.= " WHERE rowid = '".$id."';";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
@ -340,7 +394,7 @@ class Propal
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Propal::UpdateLigne Erreur -1");
|
dolibarr_syslog("Propal::UpdateLigne Erreur sql=$sql, error=".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -693,9 +747,12 @@ class Propal
|
|||||||
function create()
|
function create()
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
// Définition paramètres
|
|
||||||
|
// Nettoyage/définition paramètres
|
||||||
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
|
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
|
||||||
|
|
||||||
|
dolibarr_syslog("Propal::create ref=".$this->ref);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Insertion dans la base
|
// Insertion dans la base
|
||||||
@ -744,6 +801,7 @@ class Propal
|
|||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mise a journ infos dénormalisés
|
||||||
$resql=$this->update_price();
|
$resql=$this->update_price();
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -782,36 +840,53 @@ class Propal
|
|||||||
*/
|
*/
|
||||||
function update_price()
|
function update_price()
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT . "/lib/price.lib.php";
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Liste des produits a ajouter
|
* Liste des produits a ajouter
|
||||||
*/
|
*/
|
||||||
$sql = "SELECT price, qty, tva_tx FROM ".MAIN_DB_PREFIX."propaldet";
|
$sql = "SELECT price, qty, tva_tx, total_ht, total_tva, total_ttc";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet";
|
||||||
$sql.= " WHERE fk_propal = ".$this->id;
|
$sql.= " WHERE fk_propal = ".$this->id;
|
||||||
if ( $this->db->query($sql) )
|
$result = $this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$this->total_ht = 0;
|
||||||
$i = 0;
|
$this->total_tva = 0;
|
||||||
|
$this->total_ttc = 0;
|
||||||
|
|
||||||
|
$num = $this->db->num_rows($result);
|
||||||
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
|
$this->total_ht += $obj->total_ht;
|
||||||
|
$this->total_tva += ($obj->total_ttc - $obj->total_ht);
|
||||||
|
$this->total_ttc += $obj->total_ttc;
|
||||||
|
|
||||||
|
// Anciens indicateurs
|
||||||
|
$this->amount_ht += $obj->price * $obj->qty;
|
||||||
|
$this->total_remise += 0; // Plus de remise globale (toute remise est sur une ligne)
|
||||||
|
/* \deprecated car simplifie par les 3 indicateurs total_ht, total_tva et total_ttc sur lignes
|
||||||
$products[$i][0] = $obj->price;
|
$products[$i][0] = $obj->price;
|
||||||
$products[$i][1] = $obj->qty;
|
$products[$i][1] = $obj->qty;
|
||||||
$products[$i][2] = $obj->tva_tx;
|
$products[$i][2] = $obj->tva_tx;
|
||||||
|
*/
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$calculs = calcul_price($products, $this->remise_percent, $this->remise_absolue);
|
|
||||||
|
|
||||||
|
$this->db->free($result);
|
||||||
|
}
|
||||||
|
/* \deprecated car simplifie par les 3 indicateurs total_ht, total_tva et total_ttc sur lignes
|
||||||
|
$calculs = calcul_price($products, $this->remise_percent, $this->remise_absolue);
|
||||||
$this->total_remise = $calculs[3];
|
$this->total_remise = $calculs[3];
|
||||||
$this->amount_ht = $calculs[4];
|
$this->amount_ht = $calculs[4];
|
||||||
$this->total_ht = $calculs[0];
|
$this->total_ht = $calculs[0];
|
||||||
$this->total_tva = $calculs[1];
|
$this->total_tva = $calculs[1];
|
||||||
$this->total_ttc = $calculs[2];
|
$this->total_ttc = $calculs[2];
|
||||||
$tvas = $calculs[5];
|
$tvas = $calculs[5];
|
||||||
|
*/
|
||||||
// Met a jour en base
|
// Met a jour en base
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
|
||||||
$sql .= " price='". price2num($this->total_ht)."'";
|
$sql .= " price='". price2num($this->total_ht)."'";
|
||||||
@ -976,8 +1051,9 @@ class Propal
|
|||||||
$sql.= " WHERE fk_statut = c.id";
|
$sql.= " WHERE fk_statut = c.id";
|
||||||
$sql.= " AND rowid='".$rowid."';";
|
$sql.= " AND rowid='".$rowid."';";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
dolibarr_syslog("Propal::fecth rowid=".$rowid);
|
||||||
|
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows($resql))
|
if ($this->db->num_rows($resql))
|
||||||
@ -1061,7 +1137,8 @@ class Propal
|
|||||||
* Lignes propales liées à un produit ou non
|
* Lignes propales liées à un produit ou non
|
||||||
*/
|
*/
|
||||||
$sql = "SELECT d.description, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice, d.fk_product,";
|
$sql = "SELECT d.description, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice, d.fk_product,";
|
||||||
$sql.= " p.label, p.description as product_desc, p.ref";
|
$sql.= " d.total_ht, d.total_tva, d.total_ttc,";
|
||||||
|
$sql.= " p.ref, p.label, p.description as product_desc";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
|
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
|
||||||
$sql.= " WHERE d.fk_propal = ".$this->id;
|
$sql.= " WHERE d.fk_propal = ".$this->id;
|
||||||
@ -1077,7 +1154,7 @@ class Propal
|
|||||||
{
|
{
|
||||||
$objp = $this->db->fetch_object($result);
|
$objp = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$ligne = new PropaleLigne();
|
$ligne = new PropaleLigne($this->db);
|
||||||
|
|
||||||
$ligne->desc = $objp->description; // Description ligne
|
$ligne->desc = $objp->description; // Description ligne
|
||||||
$ligne->qty = $objp->qty;
|
$ligne->qty = $objp->qty;
|
||||||
@ -1085,6 +1162,11 @@ class Propal
|
|||||||
$ligne->subprice = $objp->subprice;
|
$ligne->subprice = $objp->subprice;
|
||||||
$ligne->remise_percent = $objp->remise_percent;
|
$ligne->remise_percent = $objp->remise_percent;
|
||||||
$ligne->price = $objp->price;
|
$ligne->price = $objp->price;
|
||||||
|
|
||||||
|
$ligne->total_ht = $objp->total_ht;
|
||||||
|
$ligne->total_tva = $objp->total_tva;
|
||||||
|
$ligne->total_ttc = $objp->total_ttc;
|
||||||
|
|
||||||
$ligne->product_id = $objp->fk_product;
|
$ligne->product_id = $objp->fk_product;
|
||||||
$ligne->coef = $objp->coef;
|
$ligne->coef = $objp->coef;
|
||||||
|
|
||||||
@ -1101,7 +1183,7 @@ class Propal
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Propal::Fetch Erreur lecture des produits");
|
dolibarr_syslog("Propal::Fetch Erreur lecture des produits sql=$sql");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2282,13 +2364,13 @@ class PropaleLigne
|
|||||||
var $subprice;
|
var $subprice;
|
||||||
var $remise_percent;
|
var $remise_percent;
|
||||||
var $price;
|
var $price;
|
||||||
var $product_id;
|
|
||||||
var $desc; // Description ligne
|
var $desc; // Description ligne
|
||||||
|
var $product_id; // Id produit prédéfini
|
||||||
|
|
||||||
// From llx_product
|
// From llx_product
|
||||||
var $libelle; // Label produit
|
var $libelle; // Label produit
|
||||||
var $product_desc; // Description produit
|
var $product_desc; // Description produit
|
||||||
var $ref;
|
var $ref; // Reference produit
|
||||||
|
|
||||||
function PropaleLigne()
|
function PropaleLigne()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -115,6 +115,10 @@ ALTER TABLE llx_facturedet ADD COLUMN total_tva real AFTER total_ht;
|
|||||||
ALTER TABLE llx_facturedet ADD COLUMN total_ttc real AFTER total_tva;
|
ALTER TABLE llx_facturedet ADD COLUMN total_ttc real AFTER total_tva;
|
||||||
ALTER TABLE llx_facturedet ADD COLUMN info_bits integer DEFAULT 0 AFTER date_end;
|
ALTER TABLE llx_facturedet ADD COLUMN info_bits integer DEFAULT 0 AFTER date_end;
|
||||||
|
|
||||||
|
ALTER TABLE llx_propaldet ADD COLUMN total_ht real AFTER price;
|
||||||
|
ALTER TABLE llx_propaldet ADD COLUMN total_tva real AFTER total_ht;
|
||||||
|
ALTER TABLE llx_propaldet ADD COLUMN total_ttc real AFTER total_tva;
|
||||||
|
ALTER TABLE llx_propaldet ADD COLUMN info_bits integer DEFAULT 0 AFTER total_ttc;
|
||||||
|
|
||||||
ALTER TABLE llx_commande ADD INDEX idx_commande_fk_soc (fk_soc);
|
ALTER TABLE llx_commande ADD INDEX idx_commande_fk_soc (fk_soc);
|
||||||
ALTER TABLE llx_commande ADD CONSTRAINT fk_commande_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp);
|
ALTER TABLE llx_commande ADD CONSTRAINT fk_commande_societe FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp);
|
||||||
|
|||||||
@ -32,6 +32,10 @@ create table llx_propaldet
|
|||||||
fk_remise_except integer NULL, -- Lien vers table des remises fixes
|
fk_remise_except integer NULL, -- Lien vers table des remises fixes
|
||||||
subprice real, -- prix avant remise
|
subprice real, -- prix avant remise
|
||||||
price real, -- prix final
|
price real, -- prix final
|
||||||
|
total_ht real, -- Total HT de la ligne toute quantité et incluant remise ligne et globale
|
||||||
|
total_tva real, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale
|
||||||
|
total_ttc real, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale
|
||||||
|
info_bits integer DEFAULT 0, -- TVA NPR ou non
|
||||||
coef real, -- coefficient de marge
|
coef real, -- coefficient de marge
|
||||||
rang integer DEFAULT 0
|
rang integer DEFAULT 0
|
||||||
)type=innodb;
|
)type=innodb;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user