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 '
'; print ''; - print '' ."\n"; + print '' ."\n"; print ''; print ''; @@ -865,7 +865,7 @@ else 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; @@ -1022,7 +1022,7 @@ else print $langs->trans('DeliveryAddress'); print ''; - if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print 'soc_id.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).''; + if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print 'socidp.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).''; print ''; print ''; @@ -1084,11 +1084,11 @@ else print ''; if ($_GET['action'] == 'classer') { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'projetid'); + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'projetid'); } else { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'none'); + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'none'); } print ''; } @@ -1734,7 +1734,7 @@ else print_titre($langs->trans('SendOrderByMail')); $soc = new Societe($db); - $soc->fetch($commande->soc_id); + $soc->fetch($commande->socidp); $liste[0]=" "; foreach ($soc->contact_email_array() as $key=>$value) diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index a590d5b25eb..37f9d4824f8 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -49,8 +49,8 @@ llxHeader(); $commande = new Commande($db); $commande->fetch($_GET["id"]); $commande->info($_GET["id"]); -$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); dolibarr_fiche_head($head, 'info', $langs->trans("CustomerOrder")); diff --git a/htdocs/companybankaccount.class.php b/htdocs/companybankaccount.class.php index 3afa09bc887..d809c3bebe4 100644 --- a/htdocs/companybankaccount.class.php +++ b/htdocs/companybankaccount.class.php @@ -21,26 +21,27 @@ class CompanyBankAccount { - var $rowid; - - var $bank; - var $courant; - var $clos; - var $code_banque; - var $code_guichet; - var $number; - var $cle_rib; - var $bic; - var $iban_prefix; - var $proprio; - var $adresse_proprio; - - function CompanyBankAccount($DB, $soc_id) - { + var $rowid; + var $socidp; + + var $bank; + var $courant; + var $clos; + var $code_banque; + var $code_guichet; + var $number; + var $cle_rib; + var $bic; + var $iban_prefix; + var $proprio; + var $adresse_proprio; + + function CompanyBankAccount($DB, $socid) + { global $config; $this->db = $DB; - $this->soc_id = $soc_id; + $this->socidp = $socid; $this->clos = 0; $this->solde = 0; @@ -55,8 +56,7 @@ class CompanyBankAccount */ function create() { - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->soc_id, now());"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socidp, now());"; if ($this->db->query($sql)) { if ($this->db->affected_rows()) @@ -79,7 +79,7 @@ class CompanyBankAccount { $sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib "; - $sql .= " WHERE fk_soc = ".$this->soc_id; + $sql .= " WHERE fk_soc = ".$this->socidp; $result = $this->db->query($sql); @@ -116,7 +116,7 @@ class CompanyBankAccount $sql .= ",proprio = '".addslashes($this->proprio)."'"; $sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'"; - $sql .= " WHERE fk_soc = ".$this->soc_id; + $sql .= " WHERE fk_soc = ".$this->socidp; $result = $this->db->query($sql); @@ -139,7 +139,7 @@ class CompanyBankAccount { $sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib"; - $sql .= " WHERE fk_soc = ".$this->soc_id; + $sql .= " WHERE fk_soc = ".$this->socidp; $result = $this->db->query($sql); diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php index d5c50646b6c..1b73725a531 100644 --- a/htdocs/compta/commande/fiche.php +++ b/htdocs/compta/commande/fiche.php @@ -80,7 +80,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(); @@ -189,7 +189,7 @@ if ($_GET["id"] > 0) print $langs->trans('DeliveryAddress'); print ''; - if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print 'soc_id.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).''; + if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print 'socidp.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).''; print ''; print ''; @@ -251,11 +251,11 @@ if ($_GET["id"] > 0) print ''; if ($_GET['action'] == 'classer') { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'projetid'); + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'projetid'); } else { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'none'); + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'none'); } print ''; } @@ -500,7 +500,7 @@ if ($_GET["id"] > 0) if ($commande->statut > 0 && $user->rights->facture->creer) { - print ''.$langs->trans("CreateBill").''; + print ''.$langs->trans("CreateBill").''; } if ($commande->statut > 0 && $user->rights->commande->creer) diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 509eb4f22ad..f41ffd054c3 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -55,7 +55,7 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $_POST["reyear"]); $deplacement->km = $_POST["km"]; - $deplacement->socid = $_POST["soc_id"]; + $deplacement->socidp = $_POST["socidp"]; $deplacement->userid = $user->id; //$_POST["km"]; $id = $deplacement->create($user); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 59f950b3d0d..96580b7b19f 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -748,7 +748,7 @@ if ($_GET['action'] == 'create') { $propal = New Propal($db); $propal->fetch($_GET['propalid']); - $societe_id = $propal->soc_id; + $societe_id = $propal->socidp; $projetid=$propal->projetidp; $soc->fetch($societe_id); @@ -761,7 +761,7 @@ if ($_GET['action'] == 'create') { $commande = New Commande($db); $commande->fetch($_GET['commandeid']); - $societe_id = $commande->soc_id; + $societe_id = $commande->socidp; $projetid=$commande-> projet_id; $ref_client=$commande->ref_client; diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 772b8f6174e..9c8e93e47c4 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -124,7 +124,7 @@ if ($_GET["propalid"] > 0) $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, 'compta', $langs->trans('Proposal')); diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index 1ca23208be4..a4410cc94c0 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -43,10 +43,11 @@ class Contrat extends CommonObject var $id; var $ref; - var $product; - + var $socidp; var $societe; // Objet societe + var $product; + var $user_author; var $user_service; var $user_cloture; @@ -301,6 +302,7 @@ class Contrat extends CommonObject $this->fk_projet = $result["fk_projet"]; + $this->socidp = $result["fk_soc"]; $this->societe->fetch($result["fk_soc"]); $this->db->free($resql); @@ -466,7 +468,7 @@ class Contrat extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat"; // $sql.= ", fk_commercial_signature, fk_commercial_suivi"; $sql.= " , ref)"; - $sql.= " VALUES (now(),".$this->soc_id.",".$user->id; + $sql.= " VALUES (now(),".$this->socidp.",".$user->id; $sql.= ",".$this->db->idate($this->date_contrat); // $sql.= ",".($this->commercial_signature_id>=0?$this->commercial_signature_id:"null"); // $sql.= ",".($this->commercial_suivi_id>=0?$this->commercial_suivi_id:"null"); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 5ec3343ab7e..1a7c4cb47b6 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -134,7 +134,7 @@ if ($_POST["action"] == 'add') $contrat = new Contrat($db); - $contrat->soc_id = $_POST["soc_id"]; + $contrat->socidp = $_POST["socidp"]; $contrat->date_contrat = $datecontrat; $contrat->commercial_suivi_id = $_POST["commercial_suivi_id"]; @@ -154,7 +154,7 @@ if ($_POST["action"] == 'add') else { $mesg='
'.$contrat->error.'
'; } - $_GET["socid"]=$_POST["soc_id"]; + $_GET["socid"]=$_POST["socidp"]; $_GET["action"]='create'; $action = ''; } @@ -330,7 +330,7 @@ if ($_GET["action"] == 'create') print ''; print ''; - print ''."\n"; + print ''."\n"; print ''; print ''; diff --git a/htdocs/don.class.php b/htdocs/don.class.php index a66537db6a6..989b609d99d 100644 --- a/htdocs/don.class.php +++ b/htdocs/don.class.php @@ -59,10 +59,10 @@ class Don /** * \brief Constructeur - * \param DB handler d'accès base - * \param soc_idp id sociét + * \param DB Handler d'accès base + * \param socidp Id société */ - function Don($DB, $soc_idp="") + function Don($DB, $socidp="") { global $langs; diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index be542bf2788..9dc5e2647dd 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -87,7 +87,7 @@ if ($_GET["id"] > 0) $commande->expedition_array(1); $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(); @@ -204,7 +204,7 @@ if ($_GET["id"] > 0) print $langs->trans('DeliveryAddress'); print ''; - if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; + if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; print '
soc_id.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'socidp.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; print ''; @@ -266,11 +266,11 @@ if ($_GET["id"] > 0) print ''; if ($_GET['action'] == 'classer') { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'projetid'); + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'projetid'); } else { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'none'); + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'none'); } print ''; } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 9f811ea3f1f..695ec52da8e 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -177,7 +177,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(); @@ -348,7 +348,7 @@ else $commande->fetch($expedition->commande_id); $soc = new Societe($db); - $soc->fetch($commande->soc_id); + $soc->fetch($commande->socidp); $h=0; $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id; @@ -649,7 +649,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 = ".$expedition->id; $resql = $db->query($sql); diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php index 08bf8bfaca9..d0a9191847d 100644 --- a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php @@ -65,7 +65,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition $this->expe->fetch_commande(); //Creation du Client $soc = new Societe($this->db); - $soc->fetch($this->expe->commande->soc_id); + $soc->fetch($this->expe->commande->socidp); //Creation de l expediteur $this->expediteur = $soc; //Creation du destinataire diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 9cbce81612f..da4b7136094 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -80,16 +80,16 @@ class Facture extends CommonObject /** * \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 Facture($DB, $soc_idp='', $facid='') + function Facture($DB, $socidp='', $facid='') { $this->db = $DB ; $this->id = $facid; - $this->socidp = $soc_idp; + $this->socidp = $socidp; $this->amount = 0; $this->remise = 0; diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index 2d5f42cb4d0..d2fe1bd9223 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -50,14 +50,14 @@ class Fichinter extends CommonObject /** * \brief Constructeur de la classe * \param DB Handler accès base de données - * \param soc_idp Id societe + * \param socidp Id societe */ - function Fichinter($DB, $soc_idp="") + function Fichinter($DB, $socidp="") { global $langs; $this->db = $DB ; - $this->socidp = $soc_idp; + $this->socidp = $socidp; $this->products = array(); $this->projet_id = 0; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index bc4af39ffc1..93ed9072304 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -132,7 +132,7 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user-> $commande = new CommandeFournisseur($db); $commande->fetch($_GET["id"]); $soc = new Societe($db); - $soc->fetch($commande->soc_id); + $soc->fetch($commande->socidp); $result = $commande->valid($user); Header("Location: fiche.php?id=".$_GET["id"]); exit; @@ -263,7 +263,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(); @@ -633,7 +633,7 @@ if ($_GET["id"] > 0) print ''.$langs->trans("Project").''; $proj = new Project($db); - $html->select_array("projetid",$proj->liste_array($commande->soc_id)); + $html->select_array("projetid",$proj->liste_array($commande->socidp)); print ""; 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) {