Qual: On renomme les champs propriétés id société de soc_id en socidp partout

This commit is contained in:
Laurent Destailleur 2006-06-19 20:35:22 +00:00
parent c37521eea2
commit 4cd9a03b93
43 changed files with 185 additions and 155 deletions

View File

@ -117,7 +117,7 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
print "Commande $s"; print "Commande $s";
$com = new Commande($db); $com = new Commande($db);
$com->soc_id = 4; $com->socidp = 4;
$com->date_commande = $dates[rand(1, sizeof($dates)-1)]; $com->date_commande = $dates[rand(1, sizeof($dates)-1)];
$com->note = $_POST["note"]; $com->note = $_POST["note"];
$com->source = 1; $com->source = 1;

View File

@ -58,10 +58,10 @@ class Cotisation
/*! /*!
\brief Cotisation \brief Cotisation
\param DB base de données \param DB base de données
\param soc_idp \param socidp
*/ */
function Cotisation($DB, $soc_idp="") function Cotisation($DB, $socidp="")
{ {
$this->db = $DB ; $this->db = $DB ;
$this->modepaiementid = 0; $this->modepaiementid = 0;

View File

@ -62,8 +62,8 @@ $socidp='';
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socidp = $user->societe_id; $socidp = $user->societe_id;
} }
// Nombre de ligne pour choix de produit/service prédéfinis // Nombre de ligne pour choix de produit/service prédéfinis
@ -211,7 +211,7 @@ if ($_POST['action'] == 'add')
$propal->ref = $_POST['ref']; $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]) if ($_POST['idprod'.$i])
{ {
@ -227,10 +227,25 @@ if ($_POST['action'] == 'add')
if ($id > 0) if ($id > 0)
{ {
// Insertion contact par defaut $error=0;
$result=$propal->add_contact($_POST["contactidp"],'CUSTOMER','external');
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 = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$error=1;
}
}
if (! $error)
{ {
$db->commit(); $db->commit();
@ -241,13 +256,12 @@ if ($_POST['action'] == 'add')
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
propale_pdf_create($db, $id, $_POST['model'], $outputlangs); propale_pdf_create($db, $id, $_POST['model'], $outputlangs);
dolibarr_syslog('Redirect to '.$_SERVER["PHP_SELF"].'?propalid='.$id);
Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$id); Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$id);
exit; exit;
} }
else else
{ {
$msg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$db->rollback(); $db->rollback();
} }
} }
@ -611,6 +625,8 @@ if ($_GET['action'] == 'down' && $user->rights->propale->creer)
} }
llxHeader(); llxHeader();
$html = new Form($db); $html = new Form($db);
@ -624,10 +640,16 @@ if ($_GET['propalid'] > 0)
if ($msg) print "$msg<br>"; if ($msg) print "$msg<br>";
$propal = new Propal($db); $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 = new Societe($db);
$societe->fetch($propal->soc_id); $societe->fetch($propal->socidp);
$head = propal_prepare_head($propal); $head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'comm', $langs->trans('Proposal')); dolibarr_fiche_head($head, 'comm', $langs->trans('Proposal'));

View File

@ -68,7 +68,7 @@ if ($_GET["propalid"])
$propal->fetch($_GET["propalid"]); $propal->fetch($_GET["propalid"]);
$societe = new Societe($db); $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][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[0][1] = "Proposition commerciale : $propal->ref"; $head[0][1] = "Proposition commerciale : $propal->ref";

View File

@ -220,8 +220,8 @@ if ($id > 0)
$propal = New Propal($db); $propal = New Propal($db);
if ( $propal->fetch($_GET['propalid'], $user->societe_id) > 0) if ( $propal->fetch($_GET['propalid'], $user->societe_id) > 0)
{ {
$soc = new Societe($db, $propal->soc_id); $soc = new Societe($db, $propal->socidp);
$soc->fetch($propal->soc_id); $soc->fetch($propal->socidp);
$head = propal_prepare_head($propal); $head = propal_prepare_head($propal);

View File

@ -56,7 +56,7 @@ $propal = new Propal($db);
$propal->fetch($_GET['propalid']); $propal->fetch($_GET['propalid']);
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($propal->soc_id); $societe->fetch($propal->socidp);
$head = propal_prepare_head($propal); $head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'info', $langs->trans('Proposal')); dolibarr_fiche_head($head, 'info', $langs->trans('Proposal'));

View File

@ -109,7 +109,7 @@ if ($_GET['propalid'])
if ( $propal->fetch($_GET['propalid']) ) if ( $propal->fetch($_GET['propalid']) )
{ {
$societe = new Societe($db); $societe = new Societe($db);
if ( $societe->fetch($propal->soc_id) ) if ( $societe->fetch($propal->socidp) )
{ {
$head = propal_prepare_head($propal); $head = propal_prepare_head($propal);
dolibarr_fiche_head($head, 'note', $langs->trans('Proposal')); dolibarr_fiche_head($head, 'note', $langs->trans('Proposal'));

View File

@ -69,12 +69,12 @@ class Commande extends CommonObject
* \brief Constructeur * \brief Constructeur
* \param DB Handler d'accès base * \param DB Handler d'accès base
*/ */
function Commande($DB, $soc_idp="", $commandeid=0) function Commande($DB, $socidp="", $commandeid=0)
{ {
global $langs; global $langs;
$langs->load('orders'); $langs->load('orders');
$this->db = $DB; $this->db = $DB;
$this->socidp = $soc_idp; $this->socidp = $socidp;
$this->id = $commandeid; $this->id = $commandeid;
$this->sources[0] = $langs->trans('OrderSource0'); $this->sources[0] = $langs->trans('OrderSource0');
@ -98,12 +98,13 @@ class Commande extends CommonObject
{ {
$propal = new Propal($this->db); $propal = new Propal($this->db);
$propal->fetch($propale_id); $propal->fetch($propale_id);
$this->lines = array(); $this->lines = array();
$this->date_commande = time(); $this->date_commande = time();
$this->source = 0; $this->source = 0;
for ($i = 0 ; $i < sizeof($propal->lignes) ; $i++) for ($i = 0 ; $i < sizeof($propal->lignes) ; $i++)
{ {
$CommLigne = new CommandeLigne(); $CommLigne = new CommandeLigne($this->db);
$CommLigne->libelle = $propal->lignes[$i]->libelle; $CommLigne->libelle = $propal->lignes[$i]->libelle;
$CommLigne->description = $propal->lignes[$i]->desc; $CommLigne->description = $propal->lignes[$i]->desc;
$CommLigne->price = $propal->lignes[$i]->subprice; $CommLigne->price = $propal->lignes[$i]->subprice;
@ -113,9 +114,15 @@ class Commande extends CommonObject
$CommLigne->remise_percent = $propal->lignes[$i]->remise_percent; $CommLigne->remise_percent = $propal->lignes[$i]->remise_percent;
$CommLigne->product_id = $propal->lignes[$i]->product_id; $CommLigne->product_id = $propal->lignes[$i]->product_id;
$this->lines[$i] = $CommLigne; $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->projetid = $propal->projetidp;
$this->cond_reglement_id = $propal->cond_reglement_id; $this->cond_reglement_id = $propal->cond_reglement_id;
$this->mode_reglement_id = $propal->mode_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 */ /* Définit la société comme un client */
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->id = $this->soc_id; $soc->id = $this->socidp;
$soc->set_as_client(); $soc->set_as_client();
$this->propale_id = $propal->id; $this->propale_id = $propal->id;
@ -160,7 +167,7 @@ class Commande extends CommonObject
// Recuperation de la nouvelle reference // Recuperation de la nouvelle reference
$objMod = new $modName($this->db); $objMod = new $modName($this->db);
$soc = new Societe($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 // on vérifie si la commande est en numérotation provisoire
$comref = substr($this->ref, 1, 4); $comref = substr($this->ref, 1, 4);
@ -335,28 +342,28 @@ class Commande extends CommonObject
if ($this->source < 0) if ($this->source < 0)
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source")); $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; return -1;
} }
if (! $remise) $remise=0; if (! $remise) $remise=0;
if (! $this->projetid) $this->projetid = 0; if (! $this->projetid) $this->projetid = 0;
$soc = new Societe($this->db); $soc = new Societe($this->db);
$result=$soc->fetch($this->soc_id); $result=$soc->fetch($this->socidp);
if ($result < 0) if ($result < 0)
{ {
$this->error="Failed to fetch company"; $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; return -2;
} }
$this->db->begin(); $this->db->begin();
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande ('; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (';
$sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client,'; $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.= ' model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison,';
$sql.= ' remise_absolue, remise_percent)'; $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->db->idate($this->date_commande).',';
$sql.= ' '.$this->source.', '; $sql.= ' '.$this->source.', ';
$sql.= " '".addslashes($this->note)."', "; $sql.= " '".addslashes($this->note)."', ";
@ -737,7 +744,6 @@ class Commande extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->ref_client = $obj->ref_client; $this->ref_client = $obj->ref_client;
$this->soc_id = $obj->fk_soc;
$this->socidp = $obj->fk_soc; $this->socidp = $obj->fk_soc;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;

View File

@ -220,8 +220,8 @@ if ($id > 0)
$commande = New Commande($db); $commande = New Commande($db);
if ( $commande->fetch($_GET['id'], $user->societe_id) > 0) if ( $commande->fetch($_GET['id'], $user->societe_id) > 0)
{ {
$soc = new Societe($db, $commande->soc_id); $soc = new Societe($db, $commande->socidp);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$head = commande_prepare_head($commande); $head = commande_prepare_head($commande);

View File

@ -89,7 +89,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
$commande = new Commande($db); $commande = new Commande($db);
$commande->soc_id = $_POST['soc_id']; $commande->socidp = $_POST['socidp'];
$commande->date_commande = $datecommande; $commande->date_commande = $datecommande;
$commande->note = $_POST['note']; $commande->note = $_POST['note'];
$commande->source = $_POST['source_id']; $commande->source = $_POST['source_id'];
@ -117,7 +117,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
if ($commande_id <= 0) if ($commande_id <= 0)
{ {
$_GET['action']='create'; $_GET['action']='create';
$_GET['socidp']=$_POST['soc_id']; $_GET['socidp']=$_POST['socidp'];
$mesg='<div class="error">'.$commande->error.'</div>'; $mesg='<div class="error">'.$commande->error.'</div>';
} }
else else
@ -322,7 +322,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
$commande = new Commande($db); $commande = new Commande($db);
$commande->fetch($_GET['id']); $commande->fetch($_GET['id']);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$result = $commande->valid($user); $result = $commande->valid($user);
} }
@ -447,7 +447,7 @@ if ($_POST['action'] == 'send')
$file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf'; $file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf';
if (is_readable($file)) if (is_readable($file))
{ {
$soc = new Societe($db, $commande->soc_id); $soc = new Societe($db, $commande->socidp);
if ($_POST['sendto']) if ($_POST['sendto'])
{ {
// Le destinataire a été fourni via le champ libre // 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->date = time(); // L'action est faite maintenant
$actioncomm->percent = 100; $actioncomm->percent = 100;
$actioncomm->contact = new Contact($db,$sendtoid); $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->user = $user; // User qui a fait l'action
$actioncomm->orderrowid = $commande->id; $actioncomm->orderrowid = $commande->id;
$ret=$actioncomm->add($user); // User qui saisi l'action $ret=$actioncomm->add($user); // User qui saisi l'action
@ -596,7 +596,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
print '<form name="crea_commande" action="fiche.php" method="post">'; print '<form name="crea_commande" action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="soc_id" value="'.$soc->id.'">' ."\n"; print '<input type="hidden" name="socidp" value="'.$soc->id.'">' ."\n";
print '<input type="hidden" name="remise_percent" value="'.$soc->remise_client.'">'; print '<input type="hidden" name="remise_percent" value="'.$soc->remise_client.'">';
print '<input name="facnumber" type="hidden" value="provisoire">'; print '<input name="facnumber" type="hidden" value="provisoire">';
@ -865,7 +865,7 @@ else
if ( $commande->fetch($_GET['id']) > 0) if ( $commande->fetch($_GET['id']) > 0)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
@ -1022,7 +1022,7 @@ else
print $langs->trans('DeliveryAddress'); print $langs->trans('DeliveryAddress');
print '</td>'; print '</td>';
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->soc_id.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>'; if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->socidp.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
@ -1084,11 +1084,11 @@ else
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($_GET['action'] == 'classer') 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 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 '</td></tr>'; print '</td></tr>';
} }
@ -1734,7 +1734,7 @@ else
print_titre($langs->trans('SendOrderByMail')); print_titre($langs->trans('SendOrderByMail'));
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$liste[0]="&nbsp;"; $liste[0]="&nbsp;";
foreach ($soc->contact_email_array() as $key=>$value) foreach ($soc->contact_email_array() as $key=>$value)

View File

@ -49,8 +49,8 @@ llxHeader();
$commande = new Commande($db); $commande = new Commande($db);
$commande->fetch($_GET["id"]); $commande->fetch($_GET["id"]);
$commande->info($_GET["id"]); $commande->info($_GET["id"]);
$soc = new Societe($db, $commande->soc_id); $soc = new Societe($db, $commande->socidp);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$head = commande_prepare_head($commande); $head = commande_prepare_head($commande);
dolibarr_fiche_head($head, 'info', $langs->trans("CustomerOrder")); dolibarr_fiche_head($head, 'info', $langs->trans("CustomerOrder"));

View File

@ -21,26 +21,27 @@
class CompanyBankAccount class CompanyBankAccount
{ {
var $rowid; var $rowid;
var $socidp;
var $bank;
var $courant; var $bank;
var $clos; var $courant;
var $code_banque; var $clos;
var $code_guichet; var $code_banque;
var $number; var $code_guichet;
var $cle_rib; var $number;
var $bic; var $cle_rib;
var $iban_prefix; var $bic;
var $proprio; var $iban_prefix;
var $adresse_proprio; var $proprio;
var $adresse_proprio;
function CompanyBankAccount($DB, $soc_id)
{ function CompanyBankAccount($DB, $socid)
{
global $config; global $config;
$this->db = $DB; $this->db = $DB;
$this->soc_id = $soc_id; $this->socidp = $socid;
$this->clos = 0; $this->clos = 0;
$this->solde = 0; $this->solde = 0;
@ -55,8 +56,7 @@ class CompanyBankAccount
*/ */
function create() function create()
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socidp, now());";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->soc_id, now());";
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
if ($this->db->affected_rows()) if ($this->db->affected_rows())
@ -79,7 +79,7 @@ class CompanyBankAccount
{ {
$sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib "; $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); $result = $this->db->query($sql);
@ -116,7 +116,7 @@ class CompanyBankAccount
$sql .= ",proprio = '".addslashes($this->proprio)."'"; $sql .= ",proprio = '".addslashes($this->proprio)."'";
$sql .= ",adresse_proprio = '".addslashes($this->adresse_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); $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 = "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); $result = $this->db->query($sql);

View File

@ -80,7 +80,7 @@ if ($_GET["id"] > 0)
if ( $commande->fetch($_GET["id"]) > 0) if ( $commande->fetch($_GET["id"]) > 0)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();
@ -189,7 +189,7 @@ if ($_GET["id"] > 0)
print $langs->trans('DeliveryAddress'); print $langs->trans('DeliveryAddress');
print '</td>'; print '</td>';
if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->soc_id.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>'; if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->socidp.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
@ -251,11 +251,11 @@ if ($_GET["id"] > 0)
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($_GET['action'] == 'classer') 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 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 '</td></tr>'; print '</td></tr>';
} }
@ -500,7 +500,7 @@ if ($_GET["id"] > 0)
if ($commande->statut > 0 && $user->rights->facture->creer) if ($commande->statut > 0 && $user->rights->facture->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;commandeid='.$commande->id.'&amp;socidp='.$commande->soc_id.'">'.$langs->trans("CreateBill").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;commandeid='.$commande->id.'&amp;socidp='.$commande->socidp.'">'.$langs->trans("CreateBill").'</a>';
} }
if ($commande->statut > 0 && $user->rights->commande->creer) if ($commande->statut > 0 && $user->rights->commande->creer)

View File

@ -55,7 +55,7 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$_POST["reyear"]); $_POST["reyear"]);
$deplacement->km = $_POST["km"]; $deplacement->km = $_POST["km"];
$deplacement->socid = $_POST["soc_id"]; $deplacement->socidp = $_POST["socidp"];
$deplacement->userid = $user->id; //$_POST["km"]; $deplacement->userid = $user->id; //$_POST["km"];
$id = $deplacement->create($user); $id = $deplacement->create($user);

View File

@ -748,7 +748,7 @@ if ($_GET['action'] == 'create')
{ {
$propal = New Propal($db); $propal = New Propal($db);
$propal->fetch($_GET['propalid']); $propal->fetch($_GET['propalid']);
$societe_id = $propal->soc_id; $societe_id = $propal->socidp;
$projetid=$propal->projetidp; $projetid=$propal->projetidp;
$soc->fetch($societe_id); $soc->fetch($societe_id);
@ -761,7 +761,7 @@ if ($_GET['action'] == 'create')
{ {
$commande = New Commande($db); $commande = New Commande($db);
$commande->fetch($_GET['commandeid']); $commande->fetch($_GET['commandeid']);
$societe_id = $commande->soc_id; $societe_id = $commande->socidp;
$projetid=$commande-> projet_id; $projetid=$commande-> projet_id;
$ref_client=$commande->ref_client; $ref_client=$commande->ref_client;

View File

@ -124,7 +124,7 @@ if ($_GET["propalid"] > 0)
$propal->fetch($_GET['propalid']); $propal->fetch($_GET['propalid']);
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($propal->soc_id); $societe->fetch($propal->socidp);
$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'));

View File

@ -43,10 +43,11 @@ class Contrat extends CommonObject
var $id; var $id;
var $ref; var $ref;
var $product; var $socidp;
var $societe; // Objet societe var $societe; // Objet societe
var $product;
var $user_author; var $user_author;
var $user_service; var $user_service;
var $user_cloture; var $user_cloture;
@ -301,6 +302,7 @@ class Contrat extends CommonObject
$this->fk_projet = $result["fk_projet"]; $this->fk_projet = $result["fk_projet"];
$this->socidp = $result["fk_soc"];
$this->societe->fetch($result["fk_soc"]); $this->societe->fetch($result["fk_soc"]);
$this->db->free($resql); $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 = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat";
// $sql.= ", fk_commercial_signature, fk_commercial_suivi"; // $sql.= ", fk_commercial_signature, fk_commercial_suivi";
$sql.= " , ref)"; $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->db->idate($this->date_contrat);
// $sql.= ",".($this->commercial_signature_id>=0?$this->commercial_signature_id:"null"); // $sql.= ",".($this->commercial_signature_id>=0?$this->commercial_signature_id:"null");
// $sql.= ",".($this->commercial_suivi_id>=0?$this->commercial_suivi_id:"null"); // $sql.= ",".($this->commercial_suivi_id>=0?$this->commercial_suivi_id:"null");

View File

@ -134,7 +134,7 @@ if ($_POST["action"] == 'add')
$contrat = new Contrat($db); $contrat = new Contrat($db);
$contrat->soc_id = $_POST["soc_id"]; $contrat->socidp = $_POST["socidp"];
$contrat->date_contrat = $datecontrat; $contrat->date_contrat = $datecontrat;
$contrat->commercial_suivi_id = $_POST["commercial_suivi_id"]; $contrat->commercial_suivi_id = $_POST["commercial_suivi_id"];
@ -154,7 +154,7 @@ if ($_POST["action"] == 'add')
else { else {
$mesg='<div class="error">'.$contrat->error.'</div>'; $mesg='<div class="error">'.$contrat->error.'</div>';
} }
$_GET["socid"]=$_POST["soc_id"]; $_GET["socid"]=$_POST["socidp"];
$_GET["action"]='create'; $_GET["action"]='create';
$action = ''; $action = '';
} }
@ -330,7 +330,7 @@ if ($_GET["action"] == 'create')
print '<form name="contrat" action="fiche.php" method="post">'; print '<form name="contrat" action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="soc_id" value="'.$soc->id.'">'."\n"; print '<input type="hidden" name="socidp" value="'.$soc->id.'">'."\n";
print '<input type="hidden" name="remise_percent" value="0">'; print '<input type="hidden" name="remise_percent" value="0">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -59,10 +59,10 @@ class Don
/** /**
* \brief Constructeur * \brief Constructeur
* \param DB handler d'accès base * \param DB Handler d'accès base
* \param soc_idp id sociét * \param socidp Id société
*/ */
function Don($DB, $soc_idp="") function Don($DB, $socidp="")
{ {
global $langs; global $langs;

View File

@ -87,7 +87,7 @@ if ($_GET["id"] > 0)
$commande->expedition_array(1); $commande->expedition_array(1);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();
@ -204,7 +204,7 @@ if ($_GET["id"] > 0)
print $langs->trans('DeliveryAddress'); print $langs->trans('DeliveryAddress');
print '</td>'; print '</td>';
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->soc_id.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>'; if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->socidp.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
@ -266,11 +266,11 @@ if ($_GET["id"] > 0)
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($_GET['action'] == 'classer') 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 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 '</td></tr>'; print '</td></tr>';
} }

View File

@ -177,7 +177,7 @@ if ($_GET["action"] == 'create')
if ( $commande->fetch($_GET["commande_id"])) if ( $commande->fetch($_GET["commande_id"]))
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();
@ -348,7 +348,7 @@ else
$commande->fetch($expedition->commande_id); $commande->fetch($expedition->commande_id);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$h=0; $h=0;
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id; $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 = "SELECT ".$db->pdate("a.datea")." as da, a.note";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $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; $sql .= " AND a.fk_commande = ".$expedition->id;
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -65,7 +65,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$this->expe->fetch_commande(); $this->expe->fetch_commande();
//Creation du Client //Creation du Client
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->expe->commande->soc_id); $soc->fetch($this->expe->commande->socidp);
//Creation de l expediteur //Creation de l expediteur
$this->expediteur = $soc; $this->expediteur = $soc;
//Creation du destinataire //Creation du destinataire

View File

@ -80,16 +80,16 @@ class Facture extends CommonObject
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param DB handler accès base de données * \param DB handler accès base de données
* \param soc_idp id societe ('' par defaut) * \param socidp id societe ('' par defaut)
* \param facid id facture ('' par defaut) * \param facid id facture ('' par defaut)
*/ */
function Facture($DB, $soc_idp='', $facid='') function Facture($DB, $socidp='', $facid='')
{ {
$this->db = $DB ; $this->db = $DB ;
$this->id = $facid; $this->id = $facid;
$this->socidp = $soc_idp; $this->socidp = $socidp;
$this->amount = 0; $this->amount = 0;
$this->remise = 0; $this->remise = 0;

View File

@ -50,14 +50,14 @@ class Fichinter extends CommonObject
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param DB Handler accès base de données * \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; global $langs;
$this->db = $DB ; $this->db = $DB ;
$this->socidp = $soc_idp; $this->socidp = $socidp;
$this->products = array(); $this->products = array();
$this->projet_id = 0; $this->projet_id = 0;

View File

@ -132,7 +132,7 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]); $commande->fetch($_GET["id"]);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$result = $commande->valid($user); $result = $commande->valid($user);
Header("Location: fiche.php?id=".$_GET["id"]); Header("Location: fiche.php?id=".$_GET["id"]);
exit; exit;
@ -263,7 +263,7 @@ if ($_GET["id"] > 0)
if ( $commande->fetch($_GET["id"]) == 0) if ( $commande->fetch($_GET["id"]) == 0)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();
@ -633,7 +633,7 @@ if ($_GET["id"] > 0)
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';
$proj = new Project($db); $proj = new Project($db);
$html->select_array("projetid",$proj->liste_array($commande->soc_id)); $html->select_array("projetid",$proj->liste_array($commande->socidp));
print "</td></tr>"; print "</td></tr>";
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Send").'"></td></tr></table></form>'; print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Send").'"></td></tr></table></form>';

View File

@ -51,7 +51,7 @@ if ($_GET["id"] > 0)
if ( $commande->fetch($_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][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id;
$addons[0][1] = $soc->nom; $addons[0][1] = $soc->nom;

View File

@ -190,7 +190,7 @@ function commande_supplier_delete_preview($db, $propalid)
$comfourn = new CommandeFournisseur($db,"",$propalid); $comfourn = new CommandeFournisseur($db,"",$propalid);
$comfourn->fetch($propalid); $comfourn->fetch($propalid);
$client = new Societe($db); $client = new Societe($db);
$client->fetch($comfourn->soc_id); $client->fetch($comfourn->socidp);
if ($conf->fournisseur->commande->dir_output) if ($conf->fournisseur->commande->dir_output)
{ {

View File

@ -728,7 +728,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->MultiCell(80,5, $langs->trans("BillTo").":"); $pdf->MultiCell(80,5, $langs->trans("BillTo").":");
// //
$client = new Societe($this->db); $client = new Societe($this->db);
$client->fetch($com->soc_id); $client->fetch($com->socidp);
$com->client = $client; $com->client = $client;
// //

View File

@ -73,7 +73,7 @@ if ($_GET["id"] > 0)
if ( $commande->fetch($_GET["id"]) == 0) if ( $commande->fetch($_GET["id"]) == 0)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();

View File

@ -114,7 +114,7 @@ class Fournisseur extends Societe
{ {
dolibarr_syslog("Fournisseur::Create_Commande"); dolibarr_syslog("Fournisseur::Create_Commande");
$comm = new CommandeFournisseur($this->db); $comm = new CommandeFournisseur($this->db);
$comm->soc_id = $this->id; $comm->socidp = $this->id;
if ($comm->create($user) > 0) if ($comm->create($user) > 0)
{ {

View File

@ -82,7 +82,7 @@ class CommandeFournisseur extends Commande
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->soc_id = $obj->fk_soc; $this->socidp = $obj->fk_soc;
$this->fourn_id = $obj->fk_soc; $this->fourn_id = $obj->fk_soc;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;
@ -202,7 +202,7 @@ class CommandeFournisseur extends Commande
// Recuperation de la nouvelle reference // Recuperation de la nouvelle reference
$objMod = new $modName($this->db); $objMod = new $modName($this->db);
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->soc_id); $soc->fetch($this->socidp);
$num = $objMod->commande_get_num($soc); $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"; $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) function create($user)
{ {
dolibarr_syslog("CommandeFournisseur::Create soc id=".$this->soc_id); dolibarr_syslog("CommandeFournisseur::Create soc id=".$this->socidp);
$this->db->begin(); $this->db->begin();
@ -547,7 +547,7 @@ class CommandeFournisseur extends Commande
$this->brouillon = 1; $this->brouillon = 1;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseur (fk_soc, date_creation, fk_user_author, fk_statut) "; $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) ) if ( $this->db->query($sql) )
{ {

View File

@ -62,14 +62,14 @@ class FactureFournisseur extends Facture
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param DB handler accès base de données * \param DB Handler accès base de données
* \param soc_idp id societe ('' par defaut) * \param socidp Id societe ('' par defaut)
* \param facid id facture ('' par defaut) * \param facid Id facture ('' par defaut)
*/ */
function FactureFournisseur($DB, $soc_idp='', $facid='') function FactureFournisseur($DB, $socidp='', $facid='')
{ {
$this->db = $DB ; $this->db = $DB ;
$this->socidp = $soc_idp; $this->socidp = $socidp;
$this->products = array(); $this->products = array();
$this->amount = 0; $this->amount = 0;
$this->remise = 0; $this->remise = 0;

View File

@ -307,7 +307,7 @@ class pdf_edison extends ModelePDFCommandes
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12); $pdf->SetFont('Arial','B',12);
$client = new Societe($this->db); $client = new Societe($this->db);
$client->fetch($com->soc_id); $client->fetch($com->socidp);
$com->client = $client; $com->client = $client;
$pdf->SetXY(102,42); $pdf->SetXY(102,42);
$pdf->MultiCell(96,5, $com->client->nom); $pdf->MultiCell(96,5, $com->client->nom);

View File

@ -726,7 +726,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell(80,5, $langs->trans("BillTo").":"); $pdf->MultiCell(80,5, $langs->trans("BillTo").":");
// //
$client = new Societe($this->db); $client = new Societe($this->db);
$client->fetch($com->soc_id); $client->fetch($com->socidp);
$com->client = $client; $com->client = $client;
// //

View File

@ -188,7 +188,7 @@ class modFacture extends DolibarrModules
$this->export_label[$r]='Factures clients et lignes de facture'; $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_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_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 "; $this->export_sql[$r]="select distinct ";
$i=0; $i=0;
foreach ($this->export_alias_array[$r] as $key => $value) foreach ($this->export_alias_array[$r] as $key => $value)

View File

@ -226,7 +226,7 @@ class modFournisseur extends DolibarrModules
$this->export_label[$r]='Factures fournisseurs et lignes de facture'; $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_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_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 "; $this->export_sql[$r]="select distinct ";
$i=0; $i=0;
foreach ($this->export_alias_array[$r] as $key => $value) foreach ($this->export_alias_array[$r] as $key => $value)

View File

@ -182,7 +182,7 @@ if ($_GET["action"] == 'create')
if ( $commande->fetch($_GET["commande_id"])) if ( $commande->fetch($_GET["commande_id"]))
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();
@ -368,7 +368,7 @@ else
$commande->fetch($livraison->commande_id); $commande->fetch($livraison->commande_id);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->socidp);
$h=0; $h=0;
if ($conf->expedition->enabled) if ($conf->expedition->enabled)
@ -668,7 +668,7 @@ else
*/ */
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note"; $sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $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; $sql .= " AND a.fk_commande = ".$livraison->id;
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -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 = "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 .=" 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 .= ", ".$this->db->pdate("l.date_livraison")." as date_livraison, l.fk_adresse_livraison, l.model_pdf";
$sql .= ", s.idp as socid"; $sql .= ", c.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $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 AND c.fk_soc = s.idp"; $sql .= " WHERE l.rowid = ".$id." AND c.rowid = l.fk_commande";
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
@ -218,7 +218,7 @@ class Livraison extends CommonObject
$this->date_creation = $obj->date_creation; $this->date_creation = $obj->date_creation;
$this->date_valid = $obj->date_valid; $this->date_valid = $obj->date_valid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->soc_id = $obj->socid; $this->socidp = $obj->fk_soc;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->commande_id = $obj->fk_commande; $this->commande_id = $obj->fk_commande;
$this->expedition_id = $obj->fk_expedition; $this->expedition_id = $obj->fk_expedition;
@ -292,7 +292,7 @@ class Livraison extends CommonObject
// Recuperation de la nouvelle reference // Recuperation de la nouvelle reference
$objMod = new $modName($this->db); $objMod = new $modName($this->db);
$soc = new Societe($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 // on vérifie si le bon de livraison est en numérotation provisoire
$livref = substr($this->ref, 1, 4); $livref = substr($this->ref, 1, 4);

View File

@ -190,7 +190,7 @@ function delivery_order_delete_preview($db, $deliveryid)
$delivery = new Livraison($db,"",$deliveryid); $delivery = new Livraison($db,"",$deliveryid);
$delivery->fetch($deliveryid); $delivery->fetch($deliveryid);
$client = new Societe($db); $client = new Societe($db);
$client->fetch($delivery->soc_id); $client->fetch($delivery->socidp);
if ($conf->livraison->dir_output) if ($conf->livraison->dir_output)
{ {

View File

@ -308,7 +308,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12); $pdf->SetFont('Arial','B',12);
$client = new Societe($this->db); $client = new Societe($this->db);
$client->fetch($delivery->soc_id); $client->fetch($delivery->socidp);
$delivery->client = $client; $delivery->client = $client;
$pdf->SetXY(102,42); $pdf->SetXY(102,42);
$pdf->MultiCell(96,5, $delivery->client->nom); $pdf->MultiCell(96,5, $delivery->client->nom);

View File

@ -732,7 +732,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->MultiCell(80,5, $langs->trans("BillTo").":"); $pdf->MultiCell(80,5, $langs->trans("BillTo").":");
// //
$client = new Societe($this->db); $client = new Societe($this->db);
$client->fetch($delivery->soc_id); $client->fetch($delivery->socidp);
$delivery->client = $client; $delivery->client = $client;
// //

View File

@ -93,15 +93,15 @@ class Propal extends CommonObject
/** /**
* \brief Constructeur * \brief Constructeur
* \param DB Handler d'accès base * \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 * \param propalid Id de la propal
*/ */
function Propal($DB, $soc_idp="", $propalid=0) function Propal($DB, $socidp="", $propalid=0)
{ {
global $langs; global $langs;
$this->db = $DB ; $this->db = $DB ;
$this->socidp = $soc_idp; $this->socidp = $socidp;
$this->id = $propalid; $this->id = $propalid;
$this->products = array(); $this->products = array();
$this->remise = 0; $this->remise = 0;
@ -131,14 +131,12 @@ class Propal extends CommonObject
*/ */
function add_product($idproduct, $qty, $remise_percent=0) function add_product($idproduct, $qty, $remise_percent=0)
{ {
if (! $qty) $qty = 1;
if ($idproduct > 0) if ($idproduct > 0)
{ {
$i = sizeof($this->products); $i = sizeof($this->products);
$this->products[$i] = $idproduct; $this->products[$i] = $idproduct;
if (!$qty)
{
$qty = 1 ;
}
$this->products_qty[$i] = $qty; $this->products_qty[$i] = $qty;
$this->products_remise_percent[$i] = $remise_percent; $this->products_remise_percent[$i] = $remise_percent;
} }
@ -424,10 +422,10 @@ class Propal extends CommonObject
$this->db->begin(); $this->db->begin();
// Insertion dans la base // 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.= " 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.= " 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.= " 0,0,".$this->db->idate($this->datep).", now(), '".$this->ref."', ".$this->author.",";
$sql.= "'".addslashes($this->note)."',"; $sql.= "'".addslashes($this->note)."',";
$sql.= "'".addslashes($this->note_public)."',"; $sql.= "'".addslashes($this->note_public)."',";
@ -456,10 +454,9 @@ class Propal extends CommonObject
$price = $prod->multiprices[$soc->price_level]; $price = $prod->multiprices[$soc->price_level];
else else
$price = $prod->price; $price = $prod->price;
$resql = $this->addline( $resql = $this->addline(
$this->id, $this->id,
$prod->libelle,
$prod->description, $prod->description,
$price, $price,
$this->products_qty[$i], $this->products_qty[$i],
@ -506,6 +503,7 @@ class Propal extends CommonObject
// Fin appel triggers // Fin appel triggers
$this->db->commit(); $this->db->commit();
dolibarr_syslog("Propal::Create done id=".$this->id);
return $this->id; return $this->id;
} }
else else
@ -526,6 +524,8 @@ class Propal extends CommonObject
return -1; return -1;
} }
$this->db->commit();
dolibarr_syslog("Propal::Create done id=".$this->id);
return $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 * \brief Recupère de la base les caractéristiques d'une propale
* \param rowid id de la propal à récupérer * \param rowid id de la propal à récupérer
* \return int <0 si ko, 0 si non trouvé, >0 si ok
*/ */
function fetch($rowid) 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("datep")." as dp";
$sql.= ", ".$this->db->pdate("fin_validite")." as dfv"; $sql.= ", ".$this->db->pdate("fin_validite")." as dfv";
$sql.= ", ".$this->db->pdate("date_livraison")." as date_livraison"; $sql.= ", ".$this->db->pdate("date_livraison")." as date_livraison";
@ -742,7 +743,7 @@ class Propal extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."propal,"; $sql.= " FROM ".MAIN_DB_PREFIX."propal,";
$sql.= " ".MAIN_DB_PREFIX."c_propalst as c"; $sql.= " ".MAIN_DB_PREFIX."c_propalst as c";
$sql.= " WHERE fk_statut = c.id"; $sql.= " WHERE fk_statut = c.id";
$sql.= " AND rowid='".$rowid."';"; $sql.= " AND rowid='".$rowid."'";
dolibarr_syslog("Propal::fecth rowid=".$rowid); dolibarr_syslog("Propal::fecth rowid=".$rowid);
@ -769,7 +770,6 @@ class Propal extends CommonObject
$this->total_tva = $obj->tva; $this->total_tva = $obj->tva;
$this->total_ttc = $obj->total; $this->total_ttc = $obj->total;
$this->socidp = $obj->fk_soc; $this->socidp = $obj->fk_soc;
$this->soc_id = $obj->fk_soc;
$this->projetidp = $obj->fk_projet; $this->projetidp = $obj->fk_projet;
$this->contactid = $obj->fk_soc_contact; $this->contactid = $obj->fk_soc_contact;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
@ -869,19 +869,21 @@ class Propal extends CommonObject
$this->lignes[$i] = $ligne; $this->lignes[$i] = $ligne;
//dolibarr_syslog("1 ".$ligne->desc); //dolibarr_syslog("1 ".$ligne->desc);
//print "xx $i ".$this->lignes[$i]->product_desc; //print "xx $i ".$this->lignes[$i]->libelle;
$i++; $i++;
} }
$this->db->free($result); $this->db->free($result);
} }
else 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 1; return 0;
} }
else else
{ {
@ -1860,7 +1862,6 @@ class Propal extends CommonObject
$this->total_tva = $src_propal->total_tva; $this->total_tva = $src_propal->total_tva;
$this->total_ttc = $src_propal->total_ttc; $this->total_ttc = $src_propal->total_ttc;
$this->socidp = $src_propal->socidp; $this->socidp = $src_propal->socidp;
$this->soc_id = $src_propal->soc_id;
$this->projetidp = $src_propal->projetidp; $this->projetidp = $src_propal->projetidp;
$this->contactid = $src_propal->contactid; $this->contactid = $src_propal->contactid;
$this->modelpdf = $src_propal->modelpdf; $this->modelpdf = $src_propal->modelpdf;
@ -1916,7 +1917,6 @@ class Propal extends CommonObject
{ {
$resql = $this->addline( $resql = $this->addline(
$this->id, $this->id,
$prod->libelle,
$prod->description, $prod->description,
$price, $price,
$ligne->qty, $ligne->qty,

View File

@ -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) 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) if ( $rib->update($user) > 0)
{ {