diff --git a/dev/generate-commande.php b/dev/generate-commande.php
index 507c908eb3d..826c3f7d247 100644
--- a/dev/generate-commande.php
+++ b/dev/generate-commande.php
@@ -117,7 +117,7 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
print "Commande $s";
$com = new Commande($db);
- $com->soc_id = 4;
+ $com->socidp = 4;
$com->date_commande = $dates[rand(1, sizeof($dates)-1)];
$com->note = $_POST["note"];
$com->source = 1;
diff --git a/htdocs/adherents/cotisation.class.php b/htdocs/adherents/cotisation.class.php
index 73947aa80cd..3956ba42117 100644
--- a/htdocs/adherents/cotisation.class.php
+++ b/htdocs/adherents/cotisation.class.php
@@ -58,10 +58,10 @@ class Cotisation
/*!
\brief Cotisation
\param DB base de données
- \param soc_idp
+ \param socidp
*/
- function Cotisation($DB, $soc_idp="")
+ function Cotisation($DB, $socidp="")
{
$this->db = $DB ;
$this->modepaiementid = 0;
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index a89a61986a9..24ec8127e38 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -62,8 +62,8 @@ $socidp='';
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
if ($user->societe_id > 0)
{
- $action = '';
- $socidp = $user->societe_id;
+ $action = '';
+ $socidp = $user->societe_id;
}
// Nombre de ligne pour choix de produit/service prédéfinis
@@ -211,7 +211,7 @@ if ($_POST['action'] == 'add')
$propal->ref = $_POST['ref'];
- for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
+ for ($i = 1 ; $i <= $conf->global->PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
{
if ($_POST['idprod'.$i])
{
@@ -227,10 +227,25 @@ if ($_POST['action'] == 'add')
if ($id > 0)
{
- // Insertion contact par defaut
- $result=$propal->add_contact($_POST["contactidp"],'CUSTOMER','external');
+ $error=0;
- if ($result > 0)
+ // Insertion contact par defaut si défini
+ if ($_POST["contactidp"])
+ {
+ $result=$propal->add_contact($_POST["contactidp"],'CUSTOMER','external');
+
+ if ($result > 0)
+ {
+ $error=0;
+ }
+ else
+ {
+ $msg = '
'.$langs->trans("ErrorFailedToAddContact").'
';
+ $error=1;
+ }
+ }
+
+ if (! $error)
{
$db->commit();
@@ -241,13 +256,12 @@ if ($_POST['action'] == 'add')
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
propale_pdf_create($db, $id, $_POST['model'], $outputlangs);
-
+ dolibarr_syslog('Redirect to '.$_SERVER["PHP_SELF"].'?propalid='.$id);
Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$id);
exit;
}
else
{
- $msg = ''.$langs->trans("ErrorFailedToAddContact").'
';
$db->rollback();
}
}
@@ -611,6 +625,8 @@ if ($_GET['action'] == 'down' && $user->rights->propale->creer)
}
+
+
llxHeader();
$html = new Form($db);
@@ -624,10 +640,16 @@ if ($_GET['propalid'] > 0)
if ($msg) print "$msg
";
$propal = new Propal($db);
- $propal->fetch($_GET['propalid']);
+
+ $result=$propal->fetch($_GET['propalid']);
+ if (! $result > 0)
+ {
+ dolibarr_print_error($db,$propal->error);
+ exit;
+ }
$societe = new Societe($db);
- $societe->fetch($propal->soc_id);
+ $societe->fetch($propal->socidp);
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'comm', $langs->trans('Proposal'));
diff --git a/htdocs/comm/propal/aideremise.php b/htdocs/comm/propal/aideremise.php
index 4c5b2fc848c..f352cb8997e 100644
--- a/htdocs/comm/propal/aideremise.php
+++ b/htdocs/comm/propal/aideremise.php
@@ -68,7 +68,7 @@ if ($_GET["propalid"])
$propal->fetch($_GET["propalid"]);
$societe = new Societe($db);
- $societe->fetch($propal->soc_id);
+ $societe->fetch($propal->socidp);
$head[0][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[0][1] = "Proposition commerciale : $propal->ref";
diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index 3dc0d553b3d..d58c4078870 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -220,8 +220,8 @@ if ($id > 0)
$propal = New Propal($db);
if ( $propal->fetch($_GET['propalid'], $user->societe_id) > 0)
{
- $soc = new Societe($db, $propal->soc_id);
- $soc->fetch($propal->soc_id);
+ $soc = new Societe($db, $propal->socidp);
+ $soc->fetch($propal->socidp);
$head = propal_prepare_head($propal);
diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php
index 2b11118dba8..dff75e7c22c 100644
--- a/htdocs/comm/propal/info.php
+++ b/htdocs/comm/propal/info.php
@@ -56,7 +56,7 @@ $propal = new Propal($db);
$propal->fetch($_GET['propalid']);
$societe = new Societe($db);
-$societe->fetch($propal->soc_id);
+$societe->fetch($propal->socidp);
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'info', $langs->trans('Proposal'));
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index ca8bf2dbe75..2045b375c1d 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -109,7 +109,7 @@ if ($_GET['propalid'])
if ( $propal->fetch($_GET['propalid']) )
{
$societe = new Societe($db);
- if ( $societe->fetch($propal->soc_id) )
+ if ( $societe->fetch($propal->socidp) )
{
$head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'note', $langs->trans('Proposal'));
diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php
index b913b393ca1..472ffa47658 100644
--- a/htdocs/commande/commande.class.php
+++ b/htdocs/commande/commande.class.php
@@ -69,12 +69,12 @@ class Commande extends CommonObject
* \brief Constructeur
* \param DB Handler d'accès base
*/
- function Commande($DB, $soc_idp="", $commandeid=0)
+ function Commande($DB, $socidp="", $commandeid=0)
{
global $langs;
$langs->load('orders');
$this->db = $DB;
- $this->socidp = $soc_idp;
+ $this->socidp = $socidp;
$this->id = $commandeid;
$this->sources[0] = $langs->trans('OrderSource0');
@@ -98,12 +98,13 @@ class Commande extends CommonObject
{
$propal = new Propal($this->db);
$propal->fetch($propale_id);
+
$this->lines = array();
$this->date_commande = time();
$this->source = 0;
for ($i = 0 ; $i < sizeof($propal->lignes) ; $i++)
{
- $CommLigne = new CommandeLigne();
+ $CommLigne = new CommandeLigne($this->db);
$CommLigne->libelle = $propal->lignes[$i]->libelle;
$CommLigne->description = $propal->lignes[$i]->desc;
$CommLigne->price = $propal->lignes[$i]->subprice;
@@ -113,9 +114,15 @@ class Commande extends CommonObject
$CommLigne->remise_percent = $propal->lignes[$i]->remise_percent;
$CommLigne->product_id = $propal->lignes[$i]->product_id;
$this->lines[$i] = $CommLigne;
+
+ // \todo La methode create doit utiliser le tableau products plutot que lines
+ // ce qui permettrait de virer ces lignes
+ $this->products[$i]=$propal->lignes[$i]->product_id;
+ $this->products_qty[$i]=$propal->lignes[$i]->qty;
+ $this->products_remise_percent[$i]=$propal->lignes[$i]->remise_percent;
}
- $this->soc_id = $propal->soc_id;
+ $this->socidp = $propal->socidp;
$this->projetid = $propal->projetidp;
$this->cond_reglement_id = $propal->cond_reglement_id;
$this->mode_reglement_id = $propal->mode_reglement_id;
@@ -126,7 +133,7 @@ class Commande extends CommonObject
/* Définit la société comme un client */
$soc = new Societe($this->db);
- $soc->id = $this->soc_id;
+ $soc->id = $this->socidp;
$soc->set_as_client();
$this->propale_id = $propal->id;
@@ -160,7 +167,7 @@ class Commande extends CommonObject
// Recuperation de la nouvelle reference
$objMod = new $modName($this->db);
$soc = new Societe($this->db);
- $soc->fetch($this->soc_id);
+ $soc->fetch($this->socidp);
// on vérifie si la commande est en numérotation provisoire
$comref = substr($this->ref, 1, 4);
@@ -335,28 +342,28 @@ class Commande extends CommonObject
if ($this->source < 0)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source"));
- dolibarr_syslog("Commande.class.php::create ".$this->error);
+ dolibarr_syslog("Commande.class.php::create ".$this->error, LOG_ERR);
return -1;
}
if (! $remise) $remise=0;
if (! $this->projetid) $this->projetid = 0;
$soc = new Societe($this->db);
- $result=$soc->fetch($this->soc_id);
+ $result=$soc->fetch($this->socidp);
if ($result < 0)
{
$this->error="Failed to fetch company";
- dolibarr_syslog("Commande.class.php::create ".$this->error);
+ dolibarr_syslog("Commande.class.php::create ".$this->error, LOG_ERR);
return -2;
}
-
+
$this->db->begin();
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (';
$sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client,';
$sql.= ' model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison,';
$sql.= ' remise_absolue, remise_percent)';
- $sql.= ' VALUES ('.$this->soc_id.', now(), '.$user->id.', '.$this->projetid.',';
+ $sql.= ' VALUES ('.$this->socidp.', now(), '.$user->id.', '.$this->projetid.',';
$sql.= ' '.$this->db->idate($this->date_commande).',';
$sql.= ' '.$this->source.', ';
$sql.= " '".addslashes($this->note)."', ";
@@ -737,7 +744,6 @@ class Commande extends CommonObject
$this->id = $obj->rowid;
$this->ref = $obj->ref;
$this->ref_client = $obj->ref_client;
- $this->soc_id = $obj->fk_soc;
$this->socidp = $obj->fk_soc;
$this->statut = $obj->fk_statut;
$this->user_author_id = $obj->fk_user_author;
diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php
index 3a4c8c7269f..69b8f0d067d 100644
--- a/htdocs/commande/contact.php
+++ b/htdocs/commande/contact.php
@@ -220,8 +220,8 @@ if ($id > 0)
$commande = New Commande($db);
if ( $commande->fetch($_GET['id'], $user->societe_id) > 0)
{
- $soc = new Societe($db, $commande->soc_id);
- $soc->fetch($commande->soc_id);
+ $soc = new Societe($db, $commande->socidp);
+ $soc->fetch($commande->socidp);
$head = commande_prepare_head($commande);
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 2cae861fde3..8f7356341bc 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -89,7 +89,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
$commande = new Commande($db);
- $commande->soc_id = $_POST['soc_id'];
+ $commande->socidp = $_POST['socidp'];
$commande->date_commande = $datecommande;
$commande->note = $_POST['note'];
$commande->source = $_POST['source_id'];
@@ -117,7 +117,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
if ($commande_id <= 0)
{
$_GET['action']='create';
- $_GET['socidp']=$_POST['soc_id'];
+ $_GET['socidp']=$_POST['socidp'];
$mesg=''.$commande->error.'
';
}
else
@@ -322,7 +322,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
$commande = new Commande($db);
$commande->fetch($_GET['id']);
$soc = new Societe($db);
- $soc->fetch($commande->soc_id);
+ $soc->fetch($commande->socidp);
$result = $commande->valid($user);
}
@@ -447,7 +447,7 @@ if ($_POST['action'] == 'send')
$file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf';
if (is_readable($file))
{
- $soc = new Societe($db, $commande->soc_id);
+ $soc = new Societe($db, $commande->socidp);
if ($_POST['sendto'])
{
// Le destinataire a été fourni via le champ libre
@@ -512,7 +512,7 @@ if ($_POST['action'] == 'send')
$actioncomm->date = time(); // L'action est faite maintenant
$actioncomm->percent = 100;
$actioncomm->contact = new Contact($db,$sendtoid);
- $actioncomm->societe = new Societe($db,$commande->soc_id);
+ $actioncomm->societe = new Societe($db,$commande->socidp);
$actioncomm->user = $user; // User qui a fait l'action
$actioncomm->orderrowid = $commande->id;
$ret=$actioncomm->add($user); // User qui saisi l'action
@@ -596,7 +596,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
print '';
diff --git a/htdocs/fourn/commande/history.php b/htdocs/fourn/commande/history.php
index e2a4aa0b063..4af044ba37f 100644
--- a/htdocs/fourn/commande/history.php
+++ b/htdocs/fourn/commande/history.php
@@ -51,7 +51,7 @@ if ($_GET["id"] > 0)
if ( $commande->fetch($_GET["id"]) == 0)
{
- $soc->fetch($commande->soc_id);
+ $soc->fetch($commande->socidp);
$addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id;
$addons[0][1] = $soc->nom;
diff --git a/htdocs/fourn/commande/modules/modules_commandefournisseur.php b/htdocs/fourn/commande/modules/modules_commandefournisseur.php
index c520584e340..08b76eaae15 100644
--- a/htdocs/fourn/commande/modules/modules_commandefournisseur.php
+++ b/htdocs/fourn/commande/modules/modules_commandefournisseur.php
@@ -190,7 +190,7 @@ function commande_supplier_delete_preview($db, $propalid)
$comfourn = new CommandeFournisseur($db,"",$propalid);
$comfourn->fetch($propalid);
$client = new Societe($db);
- $client->fetch($comfourn->soc_id);
+ $client->fetch($comfourn->socidp);
if ($conf->fournisseur->commande->dir_output)
{
diff --git a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php
index f0c2b68193a..d925422c284 100644
--- a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php
+++ b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php
@@ -728,7 +728,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->MultiCell(80,5, $langs->trans("BillTo").":");
//
$client = new Societe($this->db);
- $client->fetch($com->soc_id);
+ $client->fetch($com->socidp);
$com->client = $client;
//
diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php
index ed1a96df2fc..5b7734a46d0 100644
--- a/htdocs/fourn/commande/note.php
+++ b/htdocs/fourn/commande/note.php
@@ -73,7 +73,7 @@ if ($_GET["id"] > 0)
if ( $commande->fetch($_GET["id"]) == 0)
{
$soc = new Societe($db);
- $soc->fetch($commande->soc_id);
+ $soc->fetch($commande->socidp);
$author = new User($db);
$author->id = $commande->user_author_id;
$author->fetch();
diff --git a/htdocs/fourn/fournisseur.class.php b/htdocs/fourn/fournisseur.class.php
index dd3e9c4ff65..a21ee737511 100644
--- a/htdocs/fourn/fournisseur.class.php
+++ b/htdocs/fourn/fournisseur.class.php
@@ -114,7 +114,7 @@ class Fournisseur extends Societe
{
dolibarr_syslog("Fournisseur::Create_Commande");
$comm = new CommandeFournisseur($this->db);
- $comm->soc_id = $this->id;
+ $comm->socidp = $this->id;
if ($comm->create($user) > 0)
{
diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php
index 39c52cce59d..204f7aaae12 100644
--- a/htdocs/fourn/fournisseur.commande.class.php
+++ b/htdocs/fourn/fournisseur.commande.class.php
@@ -82,7 +82,7 @@ class CommandeFournisseur extends Commande
$this->id = $obj->rowid;
$this->ref = $obj->ref;
- $this->soc_id = $obj->fk_soc;
+ $this->socidp = $obj->fk_soc;
$this->fourn_id = $obj->fk_soc;
$this->statut = $obj->fk_statut;
$this->user_author_id = $obj->fk_user_author;
@@ -202,7 +202,7 @@ class CommandeFournisseur extends Commande
// Recuperation de la nouvelle reference
$objMod = new $modName($this->db);
$soc = new Societe($this->db);
- $soc->fetch($this->soc_id);
+ $soc->fetch($this->socidp);
$num = $objMod->commande_get_num($soc);
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande_fournisseur SET ref='$num', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id";
@@ -539,7 +539,7 @@ class CommandeFournisseur extends Commande
*/
function create($user)
{
- dolibarr_syslog("CommandeFournisseur::Create soc id=".$this->soc_id);
+ dolibarr_syslog("CommandeFournisseur::Create soc id=".$this->socidp);
$this->db->begin();
@@ -547,7 +547,7 @@ class CommandeFournisseur extends Commande
$this->brouillon = 1;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur (fk_soc, date_creation, fk_user_author, fk_statut) ";
- $sql .= " VALUES (".$this->soc_id.", now(), ".$user->id.",0)";
+ $sql .= " VALUES (".$this->socidp.", now(), ".$user->id.",0)";
if ( $this->db->query($sql) )
{
diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php
index 755faff2d9c..f36b5bf39d5 100644
--- a/htdocs/fourn/fournisseur.facture.class.php
+++ b/htdocs/fourn/fournisseur.facture.class.php
@@ -62,14 +62,14 @@ class FactureFournisseur extends Facture
/**
* \brief Constructeur de la classe
- * \param DB handler accès base de données
- * \param soc_idp id societe ('' par defaut)
- * \param facid id facture ('' par defaut)
+ * \param DB Handler accès base de données
+ * \param socidp Id societe ('' par defaut)
+ * \param facid Id facture ('' par defaut)
*/
- function FactureFournisseur($DB, $soc_idp='', $facid='')
+ function FactureFournisseur($DB, $socidp='', $facid='')
{
$this->db = $DB ;
- $this->socidp = $soc_idp;
+ $this->socidp = $socidp;
$this->products = array();
$this->amount = 0;
$this->remise = 0;
diff --git a/htdocs/includes/modules/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php
index 3e74e29572f..bffe4d469ce 100644
--- a/htdocs/includes/modules/commande/pdf_edison.modules.php
+++ b/htdocs/includes/modules/commande/pdf_edison.modules.php
@@ -307,7 +307,7 @@ class pdf_edison extends ModelePDFCommandes
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12);
$client = new Societe($this->db);
- $client->fetch($com->soc_id);
+ $client->fetch($com->socidp);
$com->client = $client;
$pdf->SetXY(102,42);
$pdf->MultiCell(96,5, $com->client->nom);
diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php
index 1000fdf5d28..e7e7606b1b6 100644
--- a/htdocs/includes/modules/commande/pdf_einstein.modules.php
+++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php
@@ -726,7 +726,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell(80,5, $langs->trans("BillTo").":");
//
$client = new Societe($this->db);
- $client->fetch($com->soc_id);
+ $client->fetch($com->socidp);
$com->client = $client;
//
diff --git a/htdocs/includes/modules/modFacture.class.php b/htdocs/includes/modules/modFacture.class.php
index 09234c571ba..188ccce3734 100644
--- a/htdocs/includes/modules/modFacture.class.php
+++ b/htdocs/includes/modules/modFacture.class.php
@@ -188,7 +188,7 @@ class modFacture extends DolibarrModules
$this->export_label[$r]='Factures clients et lignes de facture';
$this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','f.rowid'=>"Id",'f.facnumber'=>"Ref",'f.fk_soc'=>"IdCompany",'f.datec'=>"DateCreation",'f.datef'=>"DateInvoice",'f.amount'=>"Amount",'f.remise_percent'=>"GlobalDiscount",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.paye'=>"BillShortStatusPayed",'f.fk_statut'=>'Status','f.note'=>"Note",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_taux'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd");
$this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.fk_soc'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.amount'=>"invoice",'f.remise_percent'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_taux'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line");
- $this->export_alias_array[$r]=array('s.idp'=>"soc_id",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.fk_soc'=>"fk_soc",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.amount'=>"amount",'f.remise_percent'=>"globaldiscount",'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.tva_taux'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend");
+ $this->export_alias_array[$r]=array('s.idp'=>"socidp",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.fk_soc'=>"fk_soc",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.amount'=>"amount",'f.remise_percent'=>"globaldiscount",'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.tva_taux'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend");
$this->export_sql[$r]="select distinct ";
$i=0;
foreach ($this->export_alias_array[$r] as $key => $value)
diff --git a/htdocs/includes/modules/modFournisseur.class.php b/htdocs/includes/modules/modFournisseur.class.php
index 1815de4d42e..1c49b1be0eb 100644
--- a/htdocs/includes/modules/modFournisseur.class.php
+++ b/htdocs/includes/modules/modFournisseur.class.php
@@ -226,7 +226,7 @@ class modFournisseur extends DolibarrModules
$this->export_label[$r]='Factures fournisseurs et lignes de facture';
$this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','f.rowid'=>"Id",'f.facnumber'=>"Ref",'f.datec'=>"DateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.paye'=>"BillShortStatusPayed",'f.fk_statut'=>'Status','f.note'=>"Note",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_taux'=>"LineVATRate",'fd.qty'=>"LineQty");
$this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_taux'=>"invoice_line",'fd.qty'=>"invoice_line");
- $this->export_alias_array[$r]=array('s.idp'=>"soc_id",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.total_ht'=>"totalht",'f.total_ttc'=>"totalttc",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.tva_taux'=>"linevatrate",'fd.qty'=>"lineqty");
+ $this->export_alias_array[$r]=array('s.idp'=>"socidp",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.total_ht'=>"totalht",'f.total_ttc'=>"totalttc",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.tva_taux'=>"linevatrate",'fd.qty'=>"lineqty");
$this->export_sql[$r]="select distinct ";
$i=0;
foreach ($this->export_alias_array[$r] as $key => $value)
diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php
index 54cb46eedd0..2f1e27d5393 100644
--- a/htdocs/livraison/fiche.php
+++ b/htdocs/livraison/fiche.php
@@ -182,7 +182,7 @@ if ($_GET["action"] == 'create')
if ( $commande->fetch($_GET["commande_id"]))
{
$soc = new Societe($db);
- $soc->fetch($commande->soc_id);
+ $soc->fetch($commande->socidp);
$author = new User($db);
$author->id = $commande->user_author_id;
$author->fetch();
@@ -368,7 +368,7 @@ else
$commande->fetch($livraison->commande_id);
$soc = new Societe($db);
- $soc->fetch($commande->soc_id);
+ $soc->fetch($commande->socidp);
$h=0;
if ($conf->expedition->enabled)
@@ -668,7 +668,7 @@ else
*/
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
- $sql .= " WHERE a.fk_soc = ".$commande->soc_id." AND a.fk_action in (9,10)";
+ $sql .= " WHERE a.fk_soc = ".$commande->socidp." AND a.fk_action in (9,10)";
$sql .= " AND a.fk_commande = ".$livraison->id;
$resql = $db->query($sql);
diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php
index 6826b831443..510025a70ae 100644
--- a/htdocs/livraison/livraison.class.php
+++ b/htdocs/livraison/livraison.class.php
@@ -204,9 +204,9 @@ class Livraison extends CommonObject
$sql = "SELECT l.rowid, l.date_creation, l.date_valid, l.ref, l.fk_user_author,";
$sql .=" l.fk_statut, l.fk_commande, l.fk_expedition, l.fk_user_valid, l.note, l.note_public";
$sql .= ", ".$this->db->pdate("l.date_livraison")." as date_livraison, l.fk_adresse_livraison, l.model_pdf";
- $sql .= ", s.idp as socid";
- $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
- $sql .= " WHERE l.rowid = $id AND c.rowid = l.fk_commande AND c.fk_soc = s.idp";
+ $sql .= ", c.fk_soc";
+ $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c";
+ $sql .= " WHERE l.rowid = ".$id." AND c.rowid = l.fk_commande";
$result = $this->db->query($sql) ;
@@ -218,7 +218,7 @@ class Livraison extends CommonObject
$this->date_creation = $obj->date_creation;
$this->date_valid = $obj->date_valid;
$this->ref = $obj->ref;
- $this->soc_id = $obj->socid;
+ $this->socidp = $obj->fk_soc;
$this->statut = $obj->fk_statut;
$this->commande_id = $obj->fk_commande;
$this->expedition_id = $obj->fk_expedition;
@@ -292,7 +292,7 @@ class Livraison extends CommonObject
// Recuperation de la nouvelle reference
$objMod = new $modName($this->db);
$soc = new Societe($this->db);
- $soc->fetch($this->soc_id);
+ $soc->fetch($this->socidp);
// on vérifie si le bon de livraison est en numérotation provisoire
$livref = substr($this->ref, 1, 4);
diff --git a/htdocs/livraison/mods/modules_livraison.php b/htdocs/livraison/mods/modules_livraison.php
index 51516cc66f6..838008ef008 100644
--- a/htdocs/livraison/mods/modules_livraison.php
+++ b/htdocs/livraison/mods/modules_livraison.php
@@ -190,7 +190,7 @@ function delivery_order_delete_preview($db, $deliveryid)
$delivery = new Livraison($db,"",$deliveryid);
$delivery->fetch($deliveryid);
$client = new Societe($db);
- $client->fetch($delivery->soc_id);
+ $client->fetch($delivery->socidp);
if ($conf->livraison->dir_output)
{
diff --git a/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php b/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php
index 495b562cfdf..764b380e05d 100644
--- a/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php
+++ b/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php
@@ -308,7 +308,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12);
$client = new Societe($this->db);
- $client->fetch($delivery->soc_id);
+ $client->fetch($delivery->socidp);
$delivery->client = $client;
$pdf->SetXY(102,42);
$pdf->MultiCell(96,5, $delivery->client->nom);
diff --git a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php
index 5bc69932e23..ecf529c1eee 100644
--- a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php
+++ b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php
@@ -732,7 +732,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->MultiCell(80,5, $langs->trans("BillTo").":");
//
$client = new Societe($this->db);
- $client->fetch($delivery->soc_id);
+ $client->fetch($delivery->socidp);
$delivery->client = $client;
//
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index e4095074b42..9f32d41eebc 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -93,15 +93,15 @@ class Propal extends CommonObject
/**
* \brief Constructeur
* \param DB Handler d'accès base
- * \param soc_idp Id de la société
+ * \param socidp Id de la société
* \param propalid Id de la propal
*/
- function Propal($DB, $soc_idp="", $propalid=0)
+ function Propal($DB, $socidp="", $propalid=0)
{
global $langs;
$this->db = $DB ;
- $this->socidp = $soc_idp;
+ $this->socidp = $socidp;
$this->id = $propalid;
$this->products = array();
$this->remise = 0;
@@ -131,14 +131,12 @@ class Propal extends CommonObject
*/
function add_product($idproduct, $qty, $remise_percent=0)
{
+ if (! $qty) $qty = 1;
+
if ($idproduct > 0)
{
$i = sizeof($this->products);
$this->products[$i] = $idproduct;
- if (!$qty)
- {
- $qty = 1 ;
- }
$this->products_qty[$i] = $qty;
$this->products_remise_percent[$i] = $remise_percent;
}
@@ -424,10 +422,10 @@ class Propal extends CommonObject
$this->db->begin();
// Insertion dans la base
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, fk_soc_contact, price, remise, remise_percent, remise_absolue,";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, price, remise, remise_percent, remise_absolue,";
$sql.= " tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite,";
$sql.= " fk_cond_reglement, fk_mode_reglement, date_livraison, ref_client) ";
- $sql.= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, $this->remise_percent, $this->remise_absolue,";
+ $sql.= " VALUES ($this->socidp, 0, $this->remise, $this->remise_percent, $this->remise_absolue,";
$sql.= " 0,0,".$this->db->idate($this->datep).", now(), '".$this->ref."', ".$this->author.",";
$sql.= "'".addslashes($this->note)."',";
$sql.= "'".addslashes($this->note_public)."',";
@@ -456,10 +454,9 @@ class Propal extends CommonObject
$price = $prod->multiprices[$soc->price_level];
else
$price = $prod->price;
-
+
$resql = $this->addline(
$this->id,
- $prod->libelle,
$prod->description,
$price,
$this->products_qty[$i],
@@ -506,6 +503,7 @@ class Propal extends CommonObject
// Fin appel triggers
$this->db->commit();
+ dolibarr_syslog("Propal::Create done id=".$this->id);
return $this->id;
}
else
@@ -526,6 +524,8 @@ class Propal extends CommonObject
return -1;
}
+ $this->db->commit();
+ dolibarr_syslog("Propal::Create done id=".$this->id);
return $this->id;
}
@@ -725,12 +725,13 @@ class Propal extends CommonObject
}
/**
- * \brief Recupère de la base les caractéristiques d'une propale
- * \param rowid id de la propal à récupérer
+ * \brief Recupère de la base les caractéristiques d'une propale
+ * \param rowid id de la propal à récupérer
+ * \return int <0 si ko, 0 si non trouvé, >0 si ok
*/
function fetch($rowid)
{
- $sql = "SELECT ref,total,price,remise,remise_percent,remise_absolue,tva,fk_soc,fk_soc_contact";
+ $sql = "SELECT rowid,ref,total,price,remise,remise_percent,remise_absolue,tva,fk_soc,fk_soc_contact";
$sql.= ", ".$this->db->pdate("datep")." as dp";
$sql.= ", ".$this->db->pdate("fin_validite")." as dfv";
$sql.= ", ".$this->db->pdate("date_livraison")." as date_livraison";
@@ -742,7 +743,7 @@ class Propal extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."propal,";
$sql.= " ".MAIN_DB_PREFIX."c_propalst as c";
$sql.= " WHERE fk_statut = c.id";
- $sql.= " AND rowid='".$rowid."';";
+ $sql.= " AND rowid='".$rowid."'";
dolibarr_syslog("Propal::fecth rowid=".$rowid);
@@ -769,7 +770,6 @@ class Propal extends CommonObject
$this->total_tva = $obj->tva;
$this->total_ttc = $obj->total;
$this->socidp = $obj->fk_soc;
- $this->soc_id = $obj->fk_soc;
$this->projetidp = $obj->fk_projet;
$this->contactid = $obj->fk_soc_contact;
$this->modelpdf = $obj->model_pdf;
@@ -869,19 +869,21 @@ class Propal extends CommonObject
$this->lignes[$i] = $ligne;
//dolibarr_syslog("1 ".$ligne->desc);
- //print "xx $i ".$this->lignes[$i]->product_desc;
+ //print "xx $i ".$this->lignes[$i]->libelle;
$i++;
}
$this->db->free($result);
}
else
{
- dolibarr_syslog("Propal::Fetch Erreur lecture des produits sql=$sql");
+ $this->error=$this->db->error();
+ dolibarr_syslog("Propal::Fetch Error $this->error, sql=$sql");
return -1;
}
+ return 1;
}
- return 1;
+ return 0;
}
else
{
@@ -1860,7 +1862,6 @@ class Propal extends CommonObject
$this->total_tva = $src_propal->total_tva;
$this->total_ttc = $src_propal->total_ttc;
$this->socidp = $src_propal->socidp;
- $this->soc_id = $src_propal->soc_id;
$this->projetidp = $src_propal->projetidp;
$this->contactid = $src_propal->contactid;
$this->modelpdf = $src_propal->modelpdf;
@@ -1916,7 +1917,6 @@ class Propal extends CommonObject
{
$resql = $this->addline(
$this->id,
- $prod->libelle,
$prod->description,
$price,
$ligne->qty,
diff --git a/htdocs/telephonie/client/new.php b/htdocs/telephonie/client/new.php
index 599f12e4d88..603990cf199 100644
--- a/htdocs/telephonie/client/new.php
+++ b/htdocs/telephonie/client/new.php
@@ -330,7 +330,7 @@ if ($_POST["action"] == 'add')
if ((strlen(trim($_POST["rib_banque"])) + strlen(trim($_POST["rib_guichet"])) + strlen(trim($_POST["rib_compte"])) + strlen(trim($_POST["rib_cle"])))<> 0 && $verif == 'ok' && !$error)
{
- $rib->soc_id = $soc->id;
+ $rib->socidp = $soc->id;
if ( $rib->update($user) > 0)
{