Fix: changement de idp en rowid pour llx_societe et llx_socpeople afin d'unifier le code.

This commit is contained in:
Regis Houssin 2007-06-11 22:51:47 +00:00
parent d40c4e5cc1
commit 59a3a32f78
257 changed files with 1397 additions and 1305 deletions

View File

@ -42,7 +42,7 @@ include_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
define (GEN_NUMBER_COMMANDE, 10);
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
if ($db->query($sql)) { $num = $db->num_rows(); $i = 0;
while ($i < $num) {
$row = $db->fetch_row($i); $societesid[$i] = $row[0]; $i++;

View File

@ -51,7 +51,7 @@ if ($resql)
}
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
$resql = $db->query($sql);
if ($resql)
{

View File

@ -46,7 +46,7 @@ if ($db->query($sql)) {
$num = $db->num_rows(); $i = 0;
while ($i < $num) { $row = $db->fetch_row($i); $productsid[$i] = $row[0]; $i++; } }
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
if ($db->query($sql)) { $num = $db->num_rows(); $i = 0;
while ($i < $num) { $row = $db->fetch_row($i); $societesid[$i] = $row[0]; $i++; } } else { print "err"; }

View File

@ -49,7 +49,7 @@ if ($resql)
}
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
$resql = $db->query($sql);
if ($resql)
{
@ -65,7 +65,7 @@ if ($resql)
}
$contids = array();
$sql = "SELECT idp, fk_soc FROM ".MAIN_DB_PREFIX."socpeople";
$sql = "SELECT rowid, fk_soc FROM ".MAIN_DB_PREFIX."socpeople";
$resql = $db->query($sql);
if ($resql)
{

View File

@ -55,7 +55,7 @@ if ($db->query($sql)) {
$num = $db->num_rows(); $i = 0;
while ($i < $num) { $row = $db->fetch_row($i); $productsid[$i] = $row[0]; $i++; } }
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
if ($db->query($sql)) { $num = $db->num_rows(); $i = 0;
while ($i < $num) { $row = $db->fetch_row($i); $societesid[$i] = $row[0]; $i++; } } else { print "err"; }

View File

@ -827,7 +827,7 @@ ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_author (fk_user_author);
ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_valid (fk_user_valid);
ALTER TABLE llx_facture ADD INDEX idx_facture_fk_projet (fk_projet);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid);

View File

@ -687,8 +687,8 @@ class BonPrelevement
$sql .= " , ".MAIN_DB_PREFIX."societe_rib as sr";
$sql .= " WHERE f.rowid = pfd.fk_facture";
$sql .= " AND s.idp = f.fk_soc";
$sql .= " AND s.idp = sr.fk_soc";
$sql .= " AND s.rowid = f.fk_soc";
$sql .= " AND s.rowid = sr.fk_soc";
$sql .= " AND f.fk_statut = 1";
$sql .= " AND f.paye = 0";
$sql .= " AND pfd.traite = 0";

View File

@ -72,7 +72,7 @@ print_fiche_titre($langs->trans("Bookmarks"));
if ($mesg) print $mesg;
$sql = "SELECT b.fk_soc as idp, ".$db->pdate("b.dateb")." as dateb, b.rowid as bid, b.fk_user, b.url, b.target, b.title, b.favicon,";
$sql = "SELECT b.fk_soc as rowid, ".$db->pdate("b.dateb")." as dateb, b.rowid as bid, b.fk_user, b.url, b.target, b.title, b.favicon,";
$sql.= " u.login, u.name, u.firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE b.fk_user=u.rowid";
@ -117,7 +117,7 @@ if ($resql)
// Title
print "<td>";
if ($obj->idp)
if ($obj->rowid)
{
// Lien interne societe
$lieninterne=1;
@ -127,7 +127,7 @@ if ($resql)
// Pour compatibilite avec anciens bookmarks
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
$societe=new Societe($db);
$societe->fetch($obj->idp);
$societe->fetch($obj->rowid);
$obj->title=$societe->nom;
}
$title=img_object($langs->trans("ShowCompany"),"company").' '.$obj->title;

View File

@ -44,9 +44,9 @@ else
if ($_REQUEST['origin'])
{
if($_GET['type'] == 0)$idprodorigin = $_REQUEST['origin'];
if($_GET['type'] == 1)$idSupplierorigin = $_REQUEST['origin'];
if($_GET['type'] == 2)$idCompanyorigin = $_REQUEST['origin'];
if($_GET['type'] == 0)$idProdOrigin = $_REQUEST['origin'];
if($_GET['type'] == 1)$idSupplierOrigin = $_REQUEST['origin'];
if($_GET['type'] == 2)$idCompanyOrigin = $_REQUEST['origin'];
}
@ -103,13 +103,13 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
print '<div class="ok">'.$langs->trans("CategorySuccessfullyCreated",$categorie->label).'</div>';
print '<br>';
if ($idprodorigin)
if ($idProdOrigin)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/categorie.php?id='.$idprodorigin.'">'.$langs->trans("ReturnInProduct").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/categorie.php?id='.$idProdOrigin.'">'.$langs->trans("ReturnInProduct").'</a>';
}
if ($idSupplierorigin || $idCompanyorigin)
if ($idSupplierOrigin || $idCompanyOrigin)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyorigin.'">'.$langs->trans("ReturnInCompany").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'">'.$langs->trans("ReturnInCompany").'</a>';
}
print '</td></tr></table>';

View File

@ -93,12 +93,12 @@ class Client extends Societe
$this->nb=array("customers" => 0,"prospects" => 0);
$sql = "SELECT count(s.idp) as nb, s.client";
$sql = "SELECT count(s.rowid) as nb, s.client";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.client in (1,2)";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " GROUP BY s.client";
$resql=$this->db->query($sql);
if ($resql)

View File

@ -63,14 +63,14 @@ llxHeader();
*
*/
$sql = "SELECT s.nom as societe, s.idp as socid, s.client,";
$sql = "SELECT s.nom as societe, s.rowid as socid, s.client,";
$sql.= " a.id,".$db->pdate("a.datep")." as dp, a.fk_contact, a.note, a.label, a.percent as percent,";
$sql.= " c.code as acode, c.libelle,";
$sql.= " u.login, u.rowid as userid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE a.fk_soc = s.idp AND c.id=a.fk_action AND a.fk_user_author = u.rowid";
$sql.= " WHERE a.fk_soc = s.rowid AND c.id = a.fk_action AND a.fk_user_author = u.rowid";
if ($_GET["type"])
{
$sql .= " AND c.id = ".$_GET["type"];
@ -81,11 +81,11 @@ if ($_GET["time"] == "today")
}
if ($socid)
{
$sql .= " AND s.idp = ".$socid;
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
if ($status == 'done') { $sql.= " AND a.percent = 100"; }
if ($status == 'todo') { $sql.= " AND a.percent < 100"; }

View File

@ -149,9 +149,9 @@ class CommActionRapport
$pdf->SetFont('Arial','',8);
$y=$pdf->GetY()+1;
$sql = "SELECT s.nom as societe, s.idp as socid, s.client, a.id,".$this->db->pdate("a.datea")." as da, a.datea, c.libelle, u.login, a.fk_contact, a.note, a.percent as percent";
$sql = "SELECT s.nom as societe, s.rowid as socid, s.client, a.id,".$this->db->pdate("a.datea")." as da, a.datea, c.libelle, u.login, a.fk_contact, a.note, a.percent as percent";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE a.fk_soc = s.idp AND c.id=a.fk_action AND a.fk_user_author = u.rowid";
$sql .= " WHERE a.fk_soc = s.rowid AND c.id=a.fk_action AND a.fk_user_author = u.rowid";
$sql .= " AND date_format(a.datea, '%m') = ".$this->month;
$sql .= " AND date_format(a.datea, '%Y') = ".$this->year;

View File

@ -266,7 +266,7 @@ if ($conf->expedition->enabled)
$liste_propal[0] = '';
$sql ="SELECT p.rowid as id, CONCAT(p.ref, ' - ', s.nom) as lib";
$sql.=" FROM ".MAIN_DB_PREFIX."propal p, ".MAIN_DB_PREFIX."societe s";
$sql.=" WHERE s.idp = p.fk_soc AND fk_statut <> 0 ORDER BY Id";
$sql.=" WHERE s.rowid = p.fk_soc AND fk_statut <> 0 ORDER BY Id";
$resql = $db->query($sql);
if ($resql)
{

View File

@ -238,9 +238,9 @@ class AdresseLivraison
{
global $langs, $conf;
$sql = 'SELECT idp, nom, client, fournisseur';
$sql = 'SELECT rowid, nom, client, fournisseur';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe';
$sql .= ' WHERE idp = '.$socid;
$sql .= ' WHERE rowid = '.$socid;
$resqlsoc=$this->db->query($sql);
@ -251,8 +251,8 @@ class AdresseLivraison
$obj = $this->db->fetch_object($resqlsoc);
$this->nom_societe = $obj->nom;
$this->socid = $obj->idp;
$this->id = $obj->idp;
$this->socid = $obj->rowid;
$this->id = $obj->rowid;
$this->client = $obj->client;
$this->fournisseur = $obj->fournisseur;
}
@ -416,7 +416,7 @@ class AdresseLivraison
function get_nom($id)
{
$sql = "SELECT nom FROM ".MAIN_DB_PREFIX."societe WHERE idp='$id';";
$sql = "SELECT nom FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$id."';";
$result = $this->db->query($sql);
@ -442,10 +442,10 @@ class AdresseLivraison
*/
function info($id)
{
$sql = "SELECT s.idp, s.nom, ".$this->db->pdate("datec")." as datec, ".$this->db->pdate("datea")." as datea,";
$sql = "SELECT s.rowid, s.nom, ".$this->db->pdate("datec")." as datec, ".$this->db->pdate("datea")." as datea,";
$sql.= " fk_user_creat, fk_user_modif";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.idp = ".$id;
$sql.= " WHERE s.rowid = ".$id;
$result=$this->db->query($sql);
if ($result)
@ -454,7 +454,7 @@ class AdresseLivraison
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->idp;
$this->id = $obj->rowid;
if ($obj->fk_user_creat) {
$cuser = new User($this->db, $obj->fk_user_creat);

View File

@ -92,9 +92,9 @@ if ($_GET["action"] == 'delete')
print_fiche_titre($langs->trans("Bookmarks"));
$sql = "SELECT s.idp, s.nom, ".$db->pdate("b.dateb")." as dateb, b.rowid as bid, b.fk_user, b.url, b.target, u.name, u.firstname";
$sql = "SELECT s.rowid, s.nom, ".$db->pdate("b.dateb")." as dateb, b.rowid as bid, b.fk_user, b.url, b.target, u.name, u.firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE b.fk_soc = s.idp AND b.fk_user=u.rowid";
$sql.= " WHERE b.fk_soc = s.rowid AND b.fk_user=u.rowid";
if (! $user->admin) $sql.= " AND b.fk_user = ".$user->id;
$sql.= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset);
@ -131,10 +131,10 @@ if ($resql)
print "<td align=\"center\"><b>".$obj->bid."</b></td>";
print "<td><a href='".DOL_URL_ROOT."/user/fiche.php?id=".$obj->fk_user."'>".img_object($langs->trans("ShowUser"),"user").' '.$obj->name." ".$obj->firstname."</a></td>\n";
print '<td align="center">'.dolibarr_print_date($obj->dateb) ."</td>";
print "<td><a href=\"index.php?socid=$obj->idp\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom."</a></td>\n";
print "<td><a href=\"index.php?socid=".$obj->rowid."\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom."</a></td>\n";
print '<td align="center">'.$obj->url."</td>";
print '<td align="center">'.$obj->target."</td>";
print "<td><a href=\"bookmark.php?action=delete&bid=$obj->bid\">".img_delete()."</a></td>\n";
print "<td><a href=\"bookmark.php?action=delete&bid=".$obj->bid."\">".img_delete()."</a></td>\n";
print "</tr>\n";
$i++;
}

View File

@ -46,15 +46,15 @@ $search_ville=isset($_GET["search_ville"])?$_GET["search_ville"]:$_POST["search_
$search_code=isset($_GET["search_code"])?$_GET["search_code"]:$_POST["search_code"];
$sql = "SELECT s.idp, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm, s.code_client";
$sql = "SELECT s.rowid, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm, s.code_client";
if (!$user->rights->commercial->client->voir) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
if (!$user->rights->commercial->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.fk_stcomm = st.id AND s.client=1";
if ($socid) $sql .= " AND s.idp = $socid";
if ($user->societe_id) $sql .= " AND s.idp = " .$user->societe_id;
if (!$user->rights->commercial->client->voir) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
if ($user->societe_id) $sql .= " AND s.rowid = " .$user->societe_id;
if (!$user->rights->commercial->client->voir) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($search_nom) $sql .= " AND s.nom like '%".addslashes(strtolower($search_nom))."%'";
if ($search_ville) $sql .= " AND s.ville like '%".addslashes(strtolower($search_ville))."%'";
@ -119,16 +119,16 @@ if ($result)
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->rowid.'">';
print img_object($langs->trans("ShowCustomer"),"company");
print '</a>&nbsp;<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.stripslashes($obj->nom).'</a></td>';
print '</a>&nbsp;<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->rowid.'">'.stripslashes($obj->nom).'</a></td>';
print '<td>'.$obj->ville.'</td>';
print '<td>'.$obj->code_client.'</td>';
print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
print '<td align="center">';
if (defined("MAIN_MODULE_DOSSIER") && MAIN_MODULE_DOSSIER == 1)
{
print '<a href="'.DOL_URL_ROOT.'/dossier/client/fiche.php?id='.$obj->idp.'">';
print '<a href="'.DOL_URL_ROOT.'/dossier/client/fiche.php?id='.$obj->rowid.'">';
print img_folder();
print '</a>';
}

View File

@ -71,15 +71,15 @@ if ($type == "f")
*
*/
$sql = "SELECT s.idp, s.nom, st.libelle as stcomm";
$sql .= ", p.idp as cidp, p.name, p.firstname, p.email, p.phone";
$sql = "SELECT s.rowid, s.nom, st.libelle as stcomm";
$sql .= ", p.rowid as cidp, p.name, p.firstname, p.email, p.phone";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st,";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
$sql .= " ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = p.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql .= " WHERE s.fk_stcomm = st.id";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($type == "c") $sql .= " AND s.client = 1";
if ($type == "p") $sql .= " AND s.client = 2";
if ($type == "f") $sql .= " AND s.fournisseur = 1";
@ -118,7 +118,7 @@ if ($_GET["contactname"]) // acces a partir du module de recherche
}
if ($socid) {
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($limit+1, $offset);
@ -158,16 +158,16 @@ if ($result)
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'&socid='.$obj->idp.'">'.img_object($langs->trans("ShowContact"),"contact");
print '</a>&nbsp;<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'&socid='.$obj->idp.'">'.$obj->name.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowContact"),"contact");
print '</a>&nbsp;<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'&socid='.$obj->rowid.'">'.$obj->name.'</a></td>';
print "<td>$obj->firstname</TD>";
print '<td><a href="'.$_SERVER["PHP_SELF"].'?type='.$type.'&socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a>&nbsp;';
print "<a href=\"".$urlfiche."?socid=$obj->idp\">$obj->nom</a></td>\n";
print '<td><a href="'.$_SERVER["PHP_SELF"].'?type='.$type.'&socid='.$obj->rowid.'">'.img_object($langs->trans("ShowCompany"),"company").'</a>&nbsp;';
print "<a href=\"".$urlfiche."?socid=".$obj->rowid."\">$obj->nom</a></td>\n";
print '<td><a href="action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->cidp.'&socid='.$obj->idp.'">'.$obj->email.'</a>&nbsp;</td>';
print '<td><a href="action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->cidp.'&socid='.$obj->rowid.'">'.$obj->email.'</a>&nbsp;</td>';
print '<td><a href="action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->cidp.'&socid='.$obj->idp.'">'.dolibarr_print_phone($obj->phone).'</a>&nbsp;</td>';
print '<td><a href="action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->cidp.'&socid='.$obj->rowid.'">'.dolibarr_print_phone($obj->phone).'</a>&nbsp;</td>';
print "</tr>\n";
$i++;

View File

@ -71,7 +71,7 @@ if ($_POST["action"] == 'setconditions' && $user->rights->societe->creer)
$societe = new Societe($db, $_GET["socid"]);
$societe->cond_reglement=$_POST['cond_reglement_id'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET cond_reglement='".$_POST['cond_reglement_id'];
$sql.= "' WHERE idp='".$_GET["socid"]."'";
$sql.= "' WHERE rowid='".$_GET["socid"]."'";
$result = $db->query($sql);
if (! $result) dolibarr_print_error($result);
}
@ -81,7 +81,7 @@ if ($_POST["action"] == 'setmode' && $user->rights->societe->creer)
$societe = new Societe($db, $_GET["socid"]);
$societe->mode_reglement=$_POST['mode_reglement_id'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET mode_reglement='".$_POST['mode_reglement_id'];
$sql.= "' WHERE idp='".$_GET["socid"]."'";
$sql.= "' WHERE rowid='".$_GET["socid"]."'";
$result = $db->query($sql);
if (! $result) dolibarr_print_error($result);
}
@ -90,7 +90,7 @@ if ($_POST["action"] == 'setassujtva' && $user->rights->societe->creer)
{
$societe = new Societe($db, $_GET["socid"]);
$societe->tva_assuj=$_POST['assujtva_value'];
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE idp='".$socid."'";
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$socid."'";
$result = $db->query($sql);
if (! $result) dolibarr_print_error($result);
}
@ -105,7 +105,7 @@ if ($action == 'stcomm')
if ($result)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=".$socid;
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE rowid=".$socid;
$result = $db->query($sql);
}
else
@ -132,18 +132,18 @@ if ($action == 'stcomm')
*/
if ($mode == 'search') {
if ($mode-search == 'soc') {
$sql = "SELECT s.idp";
$sql = "SELECT s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
if ( $db->query($sql) ) {
if ( $db->num_rows() == 1) {
$obj = $db->fetch_object();
$socid = $obj->idp;
$socid = $obj->rowid;
}
$db->free();
}
@ -381,11 +381,11 @@ if ($socid > 0)
print '<table class="noborder" width="100%">';
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.fk_statut, p.price, p.ref, p.remise, ";
$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.price, p.ref, p.remise, ";
$sql.= " ".$db->pdate("p.datep")." as dp, ".$db->pdate("p.fin_validite")." as datelimite";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id";
$sql .= " AND s.idp = ".$objsoc->id;
$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
$sql .= " AND s.rowid = ".$objsoc->id;
$sql .= " ORDER BY p.datep DESC";
$resql=$db->query($sql);
@ -433,12 +433,12 @@ if ($socid > 0)
print '<table class="noborder" width="100%">';
$sql = "SELECT s.nom, s.idp,";
$sql = "SELECT s.nom, s.rowid,";
$sql.= " c.rowid as cid, c.total_ht, c.ref, c.fk_statut, c.facture,";
$sql.= " ".$db->pdate("c.date_commande")." as dc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
$sql.= " WHERE c.fk_soc = s.idp ";
$sql.= " AND s.idp = $objsoc->id";
$sql.= " WHERE c.fk_soc = s.rowid ";
$sql.= " AND s.rowid = ".$objsoc->id;
$sql.= " ORDER BY c.date_commande DESC";
$resql=$db->query($sql);
@ -481,10 +481,10 @@ if ($socid > 0)
print '<table class="noborder" width="100%">';
$sql = "SELECT s.nom, s.idp, c.rowid as id, c.ref as ref, c.statut, ".$db->pdate("c.datec")." as dc";
$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, ".$db->pdate("c.datec")." as dc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
$sql .= " WHERE c.fk_soc = s.idp ";
$sql .= " AND s.idp = $objsoc->id";
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = ".$objsoc->id;
$sql .= " ORDER BY c.datec DESC";
$resql=$db->query($sql);
@ -528,10 +528,10 @@ if ($socid > 0)
{
print '<table class="noborder" width="100%">';
$sql = "SELECT s.nom, s.idp, f.rowid as id, f.ref, ".$db->pdate("f.datei")." as di";
$sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, ".$db->pdate("f.datei")." as di";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
$sql .= " WHERE f.fk_soc = s.idp";
$sql .= " AND s.idp = ".$objsoc->id;
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND s.rowid = ".$objsoc->id;
$sql .= " ORDER BY f.datei DESC";
$resql=$db->query($sql);
@ -669,7 +669,7 @@ if ($socid > 0)
print '<td>&nbsp;</td>';
print "</tr>";
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note ";
$sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note ";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " WHERE p.fk_soc = ".$objsoc->id;
$sql .= " ORDER by p.datec";
@ -685,9 +685,9 @@ if ($socid > 0)
$var = !$var;
print "<tr $bc[$var]>";
$contactstatic->id=$obj->idp;
$contactstatic->name=$obj->name;
$contactstatic->firstname=$obj->firstname;
$contactstatic->id = $obj->rowid;
$contactstatic->name = $obj->name;
$contactstatic->firstname = $obj->firstname;
print '<td>';
print $contactstatic->getNomUrl(1);
if (trim($obj->note))
@ -701,7 +701,7 @@ if ($socid > 0)
if (strlen($obj->phone) && $user->clicktodial_enabled == 1)
{
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->idp.'&amp;socid='.$objsoc->id.'&amp;call='.$obj->phone.'">';
print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->rowid.'&amp;socid='.$objsoc->id.'&amp;call='.$obj->phone.'">';
print img_phone_out("Appel émis") ;
print '</td><td>';
}
@ -710,16 +710,16 @@ if ($socid > 0)
print '<td colspan="2">';
}
print '<a href="action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->idp.'&socid='.$objsoc->id.'">'.dolibarr_print_phone($obj->phone).'</a>&nbsp;</td>';
print '<td><a href="action/fiche.php?action=create&actioncode=AC_FAX&contactid='.$obj->idp.'&socid='.$objsoc->id.'">'.dolibarr_print_phone($obj->fax).'</a>&nbsp;</td>';
print '<td><a href="action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->idp.'&socid='.$objsoc->id.'">'.$obj->email.'</a>&nbsp;</td>';
print '<a href="action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">'.dolibarr_print_phone($obj->phone).'</a>&nbsp;</td>';
print '<td><a href="action/fiche.php?action=create&actioncode=AC_FAX&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">'.dolibarr_print_phone($obj->fax).'</a>&nbsp;</td>';
print '<td><a href="action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">'.$obj->email.'</a>&nbsp;</td>';
print '<td align="center">';
print "<a href=\"../contact/fiche.php?action=edit&amp;id=$obj->idp\">";
print "<a href=\"../contact/fiche.php?action=edit&amp;id=".$obj->rowid."\">";
print img_edit();
print '</a></td>';
print '<td align="center"><a href="action/fiche.php?action=create&actioncode=AC_RDV&contactid='.$obj->idp.'&socid='.$objsoc->id.'">';
print '<td align="center"><a href="action/fiche.php?action=create&actioncode=AC_RDV&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">';
print img_object($langs->trans("Rendez-Vous"),"action");
print '</a></td>';

View File

@ -131,16 +131,16 @@ if ($conf->contrat->enabled)
*/
if ($conf->propal->enabled && $user->rights->propale->lire)
{
$sql = "SELECT p.rowid, p.ref, p.price, s.idp, s.nom";
$sql = "SELECT p.rowid, p.ref, p.price, s.rowid as socid, s.nom";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_statut = 0 and p.fk_soc = s.idp";
$sql.= " WHERE p.fk_statut = 0 and p.fk_soc = s.rowid";
if ($socid)
{
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$resql=$db->query($sql);
if ($resql)
@ -160,7 +160,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
$obj = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'><td nowrap>'."<a href=\"".DOL_URL_ROOT."/comm/propal.php?propalid=".$obj->rowid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$obj->ref.'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,18).'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.dolibarr_trunc($obj->nom,18).'</a></td>';
print '<td align="right" nowrap="nowrap">'.price($obj->price).'</td></tr>';
$i++;
$total += $obj->price;
@ -183,12 +183,12 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
if ($conf->commande->enabled)
{
$langs->load("orders");
$sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.idp";
$sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE c.fk_soc = s.rowid AND c.fk_statut = 0";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql .= " AND c.fk_soc = ".$socid;
@ -212,7 +212,7 @@ if ($conf->commande->enabled)
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td nowrap><a href=\"../commande/fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref."</a></td>";
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,18).'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.dolibarr_trunc($obj->nom,18).'</a></td>';
print '<td align="right" nowrap="nowrap">'.price($obj->total_ttc).'</td></tr>';
$i++;
$total += $obj->total_ttc;
@ -233,12 +233,12 @@ if ($conf->commande->enabled)
*/
if ($conf->bookmark->enabled)
{
$sql = "SELECT s.idp, s.nom,b.rowid as bid";
$sql = "SELECT s.rowid, s.nom,b.rowid as bid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b";
$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id;
$sql .= " WHERE b.fk_soc = s.rowid AND b.fk_user = ".$user->id;
if ($socid)
{
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " ORDER BY lower(s.nom) ASC";
@ -262,7 +262,7 @@ if ($conf->commande->enabled)
$obj = $db->fetch_object();
$var = !$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->rowid.'">'.$obj->nom.'</a></td>';
print '<td align="right"><a href="index.php?action=del_bookmark&bid='.$obj->bid.'">';
print img_delete();
print '</a></td>';
@ -284,15 +284,15 @@ print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
$sql = "SELECT a.id, a.label, ".$db->pdate("a.datep")." as dp, a.fk_user_author,";
$sql.= " c.code, c.libelle,";
$sql.= " s.nom as sname, s.idp, s.client";
$sql.= " s.nom as sname, s.rowid, s.client";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.idp = a.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.rowid = a.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql .= " AND s.idp = ".$socid;
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " ORDER BY a.datep DESC, a.id DESC";
@ -324,7 +324,7 @@ if ($resql)
print '<td>'.dolibarr_trunc($obj->label,24).'</td>';
$customerstatic->id=$obj->idp;
$customerstatic->id=$obj->rowid;
$customerstatic->nom=$obj->sname;
$customerstatic->client=$obj->client;
print '<td>'.$customerstatic->getNomUrl(1,'',16).'</td>';
@ -362,18 +362,18 @@ else
$sql = "SELECT a.id, a.percent, ".$db->pdate("a.datea")." as da, a.fk_user_author,";
$sql.= " c.code, c.libelle,";
$sql.= " s.idp, s.nom as sname, s.client";
$sql.= " s.rowid, s.nom as sname, s.client";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.id=a.fk_action AND a.percent >= 100 AND s.idp = a.fk_soc";
$sql .= " WHERE c.id = a.fk_action AND a.percent >= 100 AND s.rowid = a.fk_soc";
if ($socid)
{
$sql .= " AND s.idp = ".$socid;
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
$sql .= " ORDER BY a.datea DESC";
$sql .= $db->plimit($max, 0);
@ -403,7 +403,7 @@ if ($resql)
print $libelle;
print '</a></td>';
$customerstatic->id=$obj->idp;
$customerstatic->id=$obj->rowid;
$customerstatic->nom=$obj->sname;
$customerstatic->client=$obj->client;
print '<td>'.$customerstatic->getNomUrl(1,'',24).'</td>';
@ -435,18 +435,18 @@ else
*/
if ($user->rights->societe->lire)
{
$sql = "SELECT s.idp,s.nom,".$db->pdate("datec")." as datec";
$sql = "SELECT s.rowid,s.nom,".$db->pdate("datec")." as datec";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.client = 1";
if ($socid)
{
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = $socid";
}
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
$sql .= " ORDER BY s.datec DESC";
$sql .= $db->plimit($max, 0);
@ -469,7 +469,7 @@ if ($user->rights->societe->lire)
{
$objp = $db->fetch_object($resql);
print "<tr $bc[$var]>";
print "<td nowrap><a href=\"".DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp."\">".img_object($langs->trans("ShowCustomer"),"company")." ".$objp->nom."</a></td>";
print "<td nowrap><a href=\"".DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->rowid."\">".img_object($langs->trans("ShowCustomer"),"company")." ".$objp->nom."</a></td>";
print '<td align="right" nowrap>'.dolibarr_print_date($objp->datec)."</td>";
print '</tr>';
$i++;
@ -492,18 +492,18 @@ if ($conf->contrat->enabled && 0) // \todo A REFAIRE DEPUIS NOUVEAU CONTRAT
{
$langs->load("contracts");
$sql = "SELECT s.nom, s.idp, c.statut, c.rowid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo";
$sql = "SELECT s.nom, s.rowid, c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."product as p";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.idp and c.fk_product = p.rowid";
$sql .= " WHERE c.fk_soc = s.rowid and c.fk_product = p.rowid";
if ($socid)
{
$sql .= " AND s.idp = $socid";
}
{
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
$sql .= " ORDER BY c.tms DESC";
$sql .= $db->plimit(5, 0);
@ -524,8 +524,8 @@ if ($conf->contrat->enabled && 0) // \todo A REFAIRE DEPUIS NOUVEAU CONTRAT
while ($i < $num)
{
$obj = $db->fetch_object();
print "<tr $bc[$var]><td><a href=\"../contrat/fiche.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowContract","contract"))." ".$obj->ref."</a></td>";
print "<td><a href=\"fiche.php?socid=$obj->idp\">".img_object($langs->trans("ShowCompany","company"))." ".$obj->nom."</a></td>\n";
print "<tr $bc[$var]><td><a href=\"../contrat/fiche.php?id=".$obj->contratid."\">".img_object($langs->trans("ShowContract","contract"))." ".$obj->ref."</a></td>";
print "<td><a href=\"fiche.php?socid=".$obj->rowid."\">".img_object($langs->trans("ShowCompany","company"))." ".$obj->nom."</a></td>\n";
print "<td align=\"right\">".$staticcontrat->LibStatut($obj->statut,3)."</td></tr>\n";
$var=!$var;
$i++;
@ -547,13 +547,13 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
{
$langs->load("propal");
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp";
$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = 1";
if ($socid) $sql .= " AND s.idp = $socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = 1";
if ($socid) $sql .= " AND s.rowid = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " ORDER BY p.rowid DESC";
$result=$db->query($sql);
@ -575,11 +575,11 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
print "<tr $bc[$var]><td width=\"15%\" nowrap><a href=\"propal.php?propalid=".$obj->propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$obj->ref."</a>";
if ($obj->dp < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
print "</td>";
print "<td><a href=\"fiche.php?socid=$obj->idp\">".img_object($langs->trans("ShowCompany"),"company")." ".dolibarr_trunc($obj->nom,44)."</a></td>\n";
print "<td><a href=\"fiche.php?socid=".$obj->rowid."\">".img_object($langs->trans("ShowCompany"),"company")." ".dolibarr_trunc($obj->nom,44)."</a></td>\n";
print "<td align=\"right\">";
print dolibarr_print_date($obj->dp)."</td>\n";
print "<td align=\"right\">".price($obj->price)."</td>";
print "<td align=\"center\" width=\"14\">".$propalstatic->LibStatut($obj->fk_statut,3)."</td>\n";
print "<td align=\"center\" width=\"14\">".$propalstatic->LibStatut($obj->fk_statut,3)."</td>\n";
print "</tr>\n";
$i++;
$total += $obj->price;
@ -604,16 +604,16 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
if ($conf->propal->enabled && $user->rights->propale->lire) {
$NBMAX=5;
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp";
$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.price, p.ref, p.fk_statut, ".$db->pdate("p.datep")." as dp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut > 1";
$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut > 1";
if ($socid)
{
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " ORDER BY p.rowid DESC";
$sql .= $db->plimit($NBMAX, 0);
@ -632,7 +632,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) {
print '<td nowrap>';
print '<a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans("ShowPropal"),"propal").' ';
print $objp->ref.'</a></td>';
print '<td><a href="fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'</a></td>';
print '<td><a href="fiche.php?socid='.$objp->rowid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44).'</a></td>';
print "<td>&nbsp;</td>";
print "<td align=\"right\">";
print dolibarr_print_date($objp->dp)."</td>\n";

View File

@ -1672,17 +1672,17 @@ else
$pageprev = $page - 1;
$pagenext = $page + 1;
$sql = 'SELECT s.nom, s.idp, s.client, ';
$sql = 'SELECT s.nom, s.rowid, s.client, ';
$sql.= 'p.rowid as propalid, p.price, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp,'.$db->pdate('p.fin_validite').' as dfv';
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p';
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
$sql.= ' WHERE p.fk_soc = s.idp';
$sql.= ' WHERE p.fk_soc = s.rowid';
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
if (!empty($_GET['search_ref']))
{
@ -1697,7 +1697,7 @@ else
$sql .= " AND p.price='".addslashes($_GET['search_montant_ht'])."'";
}
if ($sall) $sql.= " AND (s.nom like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%' OR pd.description like '%".addslashes($sall)."%')";
if ($socid) $sql .= ' AND s.idp = '.$socid;
if ($socid) $sql .= ' AND s.rowid = '.$socid;
if ($_GET['viewstatut'] <> '')
{
$sql .= ' AND p.fk_statut in ('.$_GET['viewstatut'].')';
@ -1764,11 +1764,11 @@ else
if ($objp->client == 1)
{
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp;
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->rowid;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objp->idp;
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objp->rowid;
}
// Société

View File

@ -81,11 +81,11 @@ if ($_GET["propalid"] > 0)
/*
* Propal
*/
$sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp, p.note,';
$sql = 'SELECT s.nom, s.rowid, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp, p.note,';
$sql.= ' p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p';
$sql.= ' WHERE p.fk_soc = s.idp AND p.rowid = '.$propal->id;
if ($socid) $sql .= ' AND s.idp = '.$socid;
$sql.= ' WHERE p.fk_soc = s.rowid AND p.rowid = '.$propal->id;
if ($socid) $sql .= ' AND s.rowid = '.$socid;
$result = $db->query($sql);
@ -95,7 +95,7 @@ if ($_GET["propalid"] > 0)
$obj = $db->fetch_object($result);
$societe = new Societe($db);
$societe->fetch($obj->idp);
$societe->fetch($obj->rowid);
print '<table class="border" width="100%">';

View File

@ -58,7 +58,7 @@ if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0
{
$sql = "SELECT sc.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.idp AND sc.fk_user = ".$user->id." AND s.client = 2";
$sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.rowid AND sc.fk_user = ".$user->id." AND s.client = 2";
if ( $db->query($sql) )
{
@ -75,7 +75,7 @@ if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0
if ($_GET["action"] == 'cstc')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"];
$sql .= " WHERE idp = ".$_GET["id"];
$sql .= " WHERE rowid = ".$_GET["id"];
$db->query($sql);
}
@ -162,12 +162,12 @@ if ($socid > 0)
*
*/
print '<table class="noborder" width="100%">';
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.fk_statut, p.price, p.ref, p.remise, ";
$sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.fk_statut, p.price, p.ref, p.remise, ";
$sql.= " ".$db->pdate("p.datep")." as dp, ".$db->pdate("p.fin_validite")." as datelimite,";
$sql.= " c.label as statut, c.id as statutid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
$sql.= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id";
$sql.= " AND s.idp = ".$societe->id;
$sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
$sql.= " AND s.rowid = ".$societe->id;
$sql.= " ORDER BY p.datep DESC";
$resql=$db->query($sql);
@ -261,7 +261,7 @@ if ($socid > 0)
print '<td>&nbsp;</td>';
print "</tr>";
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note";
$sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql.= " WHERE p.fk_soc = ".$societe->id;
$sql.= " ORDER by p.datec";
@ -277,7 +277,7 @@ if ($socid > 0)
print "<tr $bc[$var]>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->idp.'">'.img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.'</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.'</a>&nbsp;';
if (trim($obj->note))
{
@ -285,23 +285,23 @@ if ($socid > 0)
}
print '</td>';
print '<td>'.$obj->poste.'&nbsp;</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->phone;
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->phone;
if (strlen($obj->phone) && $user->clicktodial_enabled == 1)
{
print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->idp.'&amp;socid='.$societe->id.'&amp;call='.$obj->phone.'">';
print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->rowid.'&amp;socid='.$societe->id.'&amp;call='.$obj->phone.'">';
print img_phone_out("Appel émis") ;
}
print '</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_FAX&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->fax.'</a>&nbsp;</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->email.'</a>&nbsp;</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_FAX&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->fax.'</a>&nbsp;</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->email.'</a>&nbsp;</td>';
print '<td align="center">';
if ($user->rights->societe->contact->creer)
{
print "<a href=\"".DOL_URL_ROOT."/contact/fiche.php?action=edit&amp;id=$obj->idp\">";
print "<a href=\"".DOL_URL_ROOT."/contact/fiche.php?action=edit&amp;id=".$obj->rowid."\">";
print img_edit();
print '</a>';
}
@ -309,7 +309,7 @@ if ($socid > 0)
print '</td>';
print '<td align="center"><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_RDV&contactid='.$obj->idp.'&socid='.$societe->id.'">';
print '<td align="center"><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&actioncode=AC_RDV&contactid='.$obj->rowid.'&socid='.$societe->id.'">';
print img_object($langs->trans("Rendez-Vous"),"action");
print '</a></td>';

View File

@ -77,7 +77,7 @@ if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, s
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.fk_stcomm = st.id AND s.client=2";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " GROUP BY st.id";
$sql .= " ORDER BY st.id";
@ -117,8 +117,8 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE p.fk_statut = 0 and p.fk_soc = s.idp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " WHERE p.fk_statut = 0 and p.fk_soc = s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$resql=$db->query($sql);
if ($resql)
@ -164,12 +164,12 @@ print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
$sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, a.fk_user_author, a.percent,";
$sql.= " c.code, c.libelle,";
$sql.= " s.nom as sname, s.idp";
$sql.= " s.nom as sname, s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.idp = a.fk_soc AND a.fk_user_action = $user->id";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " WHERE c.id = a.fk_action AND a.percent < 100 AND s.rowid = a.fk_soc AND a.fk_user_action = ".$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " ORDER BY a.datea DESC";
$resql=$db->query($sql);
@ -199,7 +199,7 @@ if ($resql)
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$obj->id."\">".img_object($langs->trans("ShowAction"),"task").' '.$libelle.'</a></td>';
// Tiers
print '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->sname.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->sname.'</a></td>';
$i++;
}
print "</table><br>";
@ -217,13 +217,13 @@ else
*/
if ($conf->propal->enabled && $user->rights->propale->lire)
{
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid";
$sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut = 1";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.idp = $socid";
$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id AND p.fk_statut = 1";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY p.rowid DESC";
$sql .= $db->plimit(5, 0);
@ -247,7 +247,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
print "<tr $bc[$var]><td><a href=\"../propal.php?propalid=".$obj->propalid."\">";
print img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'</a></td>';
print "<td><a href=\"fiche.php?id=$obj->idp\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom."</a></td>\n";
print "<td><a href=\"fiche.php?id=".$obj->socid."\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom."</a></td>\n";
print "<td align=\"right\">";
print dolibarr_print_date($obj->dp)."</td>\n";
print "<td align=\"right\">".price($obj->price)."</td></tr>\n";
@ -266,12 +266,12 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
* Sociétés à contacter
*
*/
$sql = "SELECT s.nom, s.idp";
$sql = "SELECT s.nom, s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.fk_stcomm = 1";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " ORDER BY s.tms ASC";
$sql .= $db->plimit(15, 0);
@ -290,7 +290,7 @@ if ( $db->query($sql) )
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]><td width=\"12%\"><a href=\"".DOL_URL_ROOT."/comm/prospect/fiche.php?id=".$obj->idp."\">";
print "<tr $bc[$var]><td width=\"12%\"><a href=\"".DOL_URL_ROOT."/comm/prospect/fiche.php?id=".$obj->rowid."\">";
print img_object($langs->trans("ShowCompany"),"company");
print ' '.$obj->nom.'</a></td></tr>';
$i++;

View File

@ -66,7 +66,7 @@ $pagenext = $page + 1;
if ($_GET["action"] == 'cstc')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"];
$sql .= " WHERE idp = ".$_GET["pid"];
$sql .= " WHERE rowid = ".$_GET["pid"];
$db->query($sql);
}
@ -75,7 +75,7 @@ if ($_GET["action"] == 'cstc')
* Affichage liste
*/
$sql = "SELECT s.idp, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm, s.fk_stcomm ";
$sql = "SELECT s.rowid, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm, s.fk_stcomm ";
$sql .= ", d.nom as departement";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM (".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."societe as s";
@ -91,9 +91,9 @@ else
$sql .=")";
}
$sql .= " LEFT join ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
$sql .= " WHERE s.fk_stcomm = st.id AND s.client=2";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
$sql .= " WHERE s.fk_stcomm = st.id AND s.client = 2";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (isset($stcomm))
{
@ -102,7 +102,7 @@ if (isset($stcomm))
if ($user->societe_id)
{
$sql .= " AND s.idp = " .$user->societe_id;
$sql .= " AND s.rowid = " .$user->societe_id;
}
if ($_GET["search_nom"])
@ -133,7 +133,7 @@ if ($resql)
if ($num == 1 && $socname)
{
$obj = $db->fetch_object($resql);
Header("Location: fiche.php?socid=".$obj->idp);
Header("Location: fiche.php?socid=".$obj->rowid);
exit;
}
else
@ -181,7 +181,7 @@ if ($resql)
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$obj->idp.'">';
print '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowProspect"),"company");
print ' '.dolibarr_trunc($obj->nom,44).'</a></td>';
print "<td>".$obj->ville."&nbsp;</td>";
@ -199,7 +199,7 @@ if ($resql)
{
if ($value <> $obj->fk_stcomm)
{
print '<a href="prospects.php?pid='.$obj->idp.'&amp;pstcomm='.$value.'&amp;action=cstc&amp;'.$urladd.'">';
print '<a href="prospects.php?pid='.$obj->rowid.'&amp;pstcomm='.$value.'&amp;action=cstc&amp;'.$urladd.'">';
print img_action(0,$value);
print '</a>&nbsp;';
}

View File

@ -57,7 +57,7 @@ llxHeader();
if ($socid > 0)
{
$societe = new Societe($db);
$societe->fetch($socid, $to); // si $to='next' ajouter " AND s.idp > $socid ORDER BY idp ASC LIMIT 1";
$societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1";
/*
* Affichage onglets

View File

@ -89,12 +89,12 @@ if ($_GET["id"] > 0) {
/*
* Commande
*/
$sql = 'SELECT s.nom, s.idp, c.amount_ht, c.fk_projet, c.remise, c.tva, c.total_ttc, c.ref, c.fk_statut, '.$db->pdate('c.date_commande').' as dp, c.note,';
$sql = 'SELECT s.nom, s.rowid, c.amount_ht, c.fk_projet, c.remise, c.tva, c.total_ttc, c.ref, c.fk_statut, '.$db->pdate('c.date_commande').' as dp, c.note,';
$sql.= ' c.fk_user_author, c.fk_user_valid, c.fk_user_cloture, c.date_creation, c.date_valid, c.date_cloture';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande as c';
$sql.= ' WHERE c.fk_soc = s.idp';
$sql.= ' WHERE c.fk_soc = s.rowid';
$sql.= ' AND c.rowid = '.$commande->id;
if ($socid) $sql .= ' AND s.idp = '.$socid;
if ($socid) $sql .= ' AND s.rowid = '.$socid;
$result = $db->query($sql);
@ -105,7 +105,7 @@ if ($_GET["id"] > 0) {
$obj = $db->fetch_object($result);
$societe = new Societe($db);
$societe->fetch($obj->idp);
$societe->fetch($obj->rowid);
print '<table class="border" width="100%">';

View File

@ -2200,7 +2200,7 @@ class Commande extends CommonObject
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{

View File

@ -699,16 +699,19 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
if ($propalid)
{
$sql = 'SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.remise_percent, p.tva, p.total, p.ref, p.fk_cond_reglement, p.fk_mode_reglement, '.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst';
$sql = 'SELECT s.nom, s.prefix_comm, s.rowid';
$sql.= ', p.price, p.remise, p.remise_percent, p.tva, p.total, p.ref, p.fk_cond_reglement, p.fk_mode_reglement';
$sql.= ', '.$db->pdate('p.datep').' as dp';
$sql.= ', c.id as statut, c.label as lst';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c';
$sql .= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id';
$sql .= ' WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id';
$sql .= ' AND p.rowid = '.$propalid;
}
else
{
$sql = 'SELECT s.nom, s.prefix_comm, s.idp, s.mode_reglement, s.cond_reglement ';
$sql = 'SELECT s.nom, s.prefix_comm, s.rowid, s.mode_reglement, s.cond_reglement ';
$sql .= 'FROM '.MAIN_DB_PREFIX.'societe as s ';
$sql .= 'WHERE s.idp = '.$_GET['socid'];
$sql .= 'WHERE s.rowid = '.$_GET['socid'];
}
$resql = $db->query($sql);
if ( $resql )
@ -719,7 +722,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
$obj = $db->fetch_object($resql);
$soc = new Societe($db);
$soc->fetch($obj->idp);
$soc->fetch($obj->rowid);
$nbrow=7;

View File

@ -72,13 +72,13 @@ print "</form></table><br>\n";
/*
* Commandes brouillons
*/
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
$sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0";
$sql .= " WHERE c.fk_soc = s.rowid AND c.fk_statut = 0";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ( $db->query($sql) )
{
@ -95,8 +95,8 @@ if ( $db->query($sql) )
{
$var=!$var;
$obj = $db->fetch_object();
print "<tr $bc[$var]><td nowrap><a href=\"fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,24).'</a></td></tr>';
print "<tr $bc[$var]><td nowrap><a href=\"fiche.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,24).'</a></td></tr>';
$i++;
}
print "</table><br>";
@ -106,13 +106,13 @@ if ( $db->query($sql) )
/*
* Commandes à traiter
*/
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
$sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .=" FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 1";
$sql .= " WHERE c.fk_soc = s.rowid AND c.fk_statut = 1";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " ORDER BY c.rowid DESC";
if ( $db->query($sql) )
@ -130,8 +130,8 @@ if ( $db->query($sql) )
{
$var=!$var;
$obj = $db->fetch_object();
print "<tr $bc[$var]><td nowrap><a href=\"fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,24).'</a></td></tr>';
print "<tr $bc[$var]><td nowrap><a href=\"fiche.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,24).'</a></td></tr>';
$i++;
}
}
@ -146,13 +146,13 @@ print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
/*
* Commandes en cours
*/
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.idp";
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 2 ";
$sql .= " WHERE c.fk_soc = s.rowid AND c.fk_statut = 2 ";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " ORDER BY c.rowid DESC";
if ( $db->query($sql) )
@ -170,9 +170,9 @@ if ( $db->query($sql) )
{
$var=!$var;
$obj = $db->fetch_object();
print "<tr $bc[$var]><td width=\"30%\"><a href=\"fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").' ';
print "<tr $bc[$var]><td width=\"30%\"><a href=\"fiche.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowOrder"),"order").' ';
print $obj->ref.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td align="right">'.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).'</td>';
print '</tr>';
$i++;
@ -186,14 +186,14 @@ if ( $db->query($sql) )
*/
$max=5;
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.idp,";
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.rowid as socid,";
$sql.= " ".$db->pdate("date_cloture")." as datec";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.idp and c.fk_statut > 2";
$sql.= " WHERE c.fk_soc = s.rowid and c.fk_statut > 2";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY c.tms DESC";
$sql.= $db->plimit($max, 0);
@ -213,9 +213,9 @@ if ($resql)
{
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td><a href=\"fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrders"),"order").' ';
print "<tr $bc[$var]><td><a href=\"fiche.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowOrders"),"order").' ';
print $obj->ref.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td>'.dolibarr_print_date($obj->datec).'</td>';
print '<td align="right">'.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).'</td>';
print '</tr>';

View File

@ -70,15 +70,15 @@ if (! $sortorder) $sortorder='DESC';
$limit = $conf->liste_limit;
$offset = $limit * $_GET['page'] ;
$sql = 'SELECT s.nom, s.idp, c.rowid, c.ref, c.total_ht, c.ref_client,';
$sql = 'SELECT s.nom, s.rowid as socid, c.rowid, c.ref, c.total_ht, c.ref_client,';
$sql.= ' '.$db->pdate('c.date_commande').' as date_commande, c.fk_statut, c.facture as facturee';
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande as c';
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ' WHERE c.fk_soc = s.idp';
$sql.= ' WHERE c.fk_soc = s.rowid';
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
if ($sref)
{
@ -90,7 +90,7 @@ if ($sall)
}
if ($socid)
{
$sql .= ' AND s.idp = '.$socid;
$sql .= ' AND s.rowid = '.$socid;
}
if ($viewstatut <> '')
{
@ -181,7 +181,7 @@ if ($resql)
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td><a href="fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('ShowOrder'),'order').' '.$objp->ref.'</a></td>';
print '<td><a href="../comm/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
print '<td><a href="../comm/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
print '<td>'.$objp->ref_client.'</td>';
print '<td>&nbsp;</td>';
print '<td align="right">';

View File

@ -170,22 +170,20 @@ class CommonObject
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,";
if ($source == 'internal') $sql.=" '-1' as socid,";
if ($source == 'external') $sql.=" t.fk_soc as socid,";
if ($source == 'internal') $sql.=" t.name as nom,";
if ($source == 'external') $sql.=" t.name as nom,";
$sql.=" t.name as nom,";
$sql.= "tc.source, tc.element, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
if ($source == 'internal') $sql.=" ".MAIN_DB_PREFIX."user t,";
if ($source == 'external') $sql.=" ".MAIN_DB_PREFIX."socpeople t,";
$sql.= " ".MAIN_DB_PREFIX."c_type_contact tc";
$sql.= " WHERE element_id =".$this->id;
$sql.= " WHERE ec.element_id =".$this->id;
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element='".$this->element."'";
if ($source == 'internal') $sql.= " AND tc.source = 'internal'";
if ($source == 'external') $sql.= " AND tc.source = 'external'";
$sql.= " AND tc.active=1";
if ($source == 'internal') $sql.= " AND ec.fk_socpeople = t.rowid";
if ($source == 'external') $sql.= " AND ec.fk_socpeople = t.idp";
if ($statut >= 0) $sql.= " AND statut = '$statut'";
$sql.= " AND ec.fk_socpeople = t.rowid";
if ($statut >= 0) $sql.= " AND ec.statut = '".$statut."'";
$sql.=" ORDER BY t.name ASC";
$resql=$this->db->query($sql);
@ -222,9 +220,9 @@ class CommonObject
{
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql.= " tc.code, tc.libelle,";
$sql.= " s.fk_soc";
$sql.= " s.fk_soc";
$sql.= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as s ON ec.fk_socpeople=s.idp"; // Si contact de type external, alors il est lié à une societe
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as s ON ec.fk_socpeople=s.rowid"; // Si contact de type external, alors il est lié à une societe
$sql.= " WHERE ec.rowid =".$rowid;
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element = '".$this->element."'";
@ -385,7 +383,7 @@ class CommonObject
function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany')
{
// On recherche les societes
$sql = "SELECT s.idp, s.nom FROM";
$sql = "SELECT s.rowid, s.nom FROM";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
//if ($filter) $sql .= " WHERE $filter";
$sql .= " ORDER BY nom ASC";
@ -402,15 +400,15 @@ class CommonObject
while ($i < $num)
{
$obj = $object->db->fetch_object($resql);
if ($i == 0) $firstCompany = $obj->idp;
if ($selected > 0 && $selected == $obj->idp)
if ($i == 0) $firstCompany = $obj->rowid;
if ($selected > 0 && $selected == $obj->rowid)
{
print '<option value="'.$obj->idp.'" selected="true">'.dolibarr_trunc($obj->nom,24).'</option>';
$firstCompany = $obj->idp;
print '<option value="'.$obj->rowid.'" selected="true">'.dolibarr_trunc($obj->nom,24).'</option>';
$firstCompany = $obj->rowid;
}
else
{
print '<option value="'.$obj->idp.'">'.dolibarr_trunc($obj->nom,24).'</option>';
print '<option value="'.$obj->rowid.'">'.dolibarr_trunc($obj->nom,24).'</option>';
}
$i ++;
}

View File

@ -183,7 +183,7 @@ if ($account > 0)
if ($mode_search)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.idp";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
}
$sql.= " WHERE b.fk_account=".$acct->id;
$sql.= $sql_rech;
@ -355,7 +355,7 @@ if ($account > 0)
$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do,".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type";
if ($mode_search)
{
$sql.= " ,s.idp as socid, s.nom as thirdparty";
$sql.= ", s.rowid as socid, s.nom as thirdparty";
}
if ($mode_search && $conf->adherent->enabled)
{
@ -369,19 +369,19 @@ if ($account > 0)
if ($mode_search)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.idp";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
}
if ($mode_search && $conf->adherent->enabled)
{
// \TODO Mettre jointure sur adherent
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'";
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.idp";
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
}
if ($mode_search && $conf->tax->enabled)
{
// \TODO Mettre jointure sur charges sociales
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'";
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.idp";
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
}
$sql.= " WHERE fk_account=".$acct->id;
$sql.= $sql_rech;

View File

@ -213,7 +213,7 @@ function gljCreateCompany($db, $company_name, $address, $cp, $ville, $fkpays, $p
/*
* Create a new company
* - insert data in table societe
* - return company's idp
* - return company's rowid
*/
// Check validity
@ -236,20 +236,20 @@ function gljCreateCompany($db, $company_name, $address, $cp, $ville, $fkpays, $p
} else {
$token = uniqid("SOC");
}
$sql .= ",'$token'";
$sql .= ",'".$token."'";
}
$sql .= ");";
if ( $db->query($sql) ) {
$sql = "SELECT idp FROM societe WHERE id= '$token';";
$sql = "SELECT rowid FROM societe WHERE id= '".$token."';";
if ( $db->query($sql) ) {
if ( $db->num_rows() ) {
$obj = $db->fetch_object();
return $obj->idp;
return $obj->rowid;
$db->free();
$sql = "INSERT INTO socpeople (datec, name, firstname, fk_soc, phone, fax, email)";
$sql .= "VALUES (now(),'$c_nom','$c_prenom', $obj->idp, $phone, $fax,$url, '$c_mail')";
$sql .= "VALUES (now(),'".$c_nom."','".$c_prenom."', ".$obj->rowid.", ".$phone.", ".$fax.", ".$url.", '".$c_mail."')";
if ( $db->query($sql) ) {
}

View File

@ -68,7 +68,7 @@ if ($action == 'attribute_prefix')
if ($action == 'note')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='$note' WHERE idp=$socid";
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$note."' WHERE rowid=".$socid;
$result = $db->query($sql);
}
@ -82,7 +82,7 @@ if ($action == 'stcomm')
if ($result)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=$socid";
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=".$stcommid." WHERE rowid=".$socid;
$result = $db->query($sql);
}
else
@ -109,14 +109,14 @@ if ($action == 'stcomm')
*/
if ($mode == 'search') {
if ($mode-search == 'soc') {
$sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s ";
$sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s ";
$sql .= " WHERE lower(s.nom) like '%".addslashes(strtolower($socname))."%'";
}
if ( $db->query($sql) ) {
if ( $db->num_rows() == 1) {
$obj = $db->fetch_object();
$socid = $obj->idp;
$socid = $obj->rowid;
}
$db->free();
}
@ -129,13 +129,13 @@ if ($mode == 'search') {
*
*/
$sql = "SELECT s.idp, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea";
$sql = "SELECT s.rowid, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea";
$sql .= ", st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.fk_stcomm = st.id AND s.client=1";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (strlen($stcomm))
{
@ -171,7 +171,7 @@ if (strlen($begin))
if ($socid)
{
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
@ -232,9 +232,9 @@ if ($result)
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->rowid.'">';
print img_object($langs->trans("ShowCustomer"),"company");
print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->rowid.'">'.$obj->nom.'</a></td>';
print '<td>'.$obj->ville.'&nbsp;</td>';
print '<td align="left">'.$obj->code_client.'&nbsp;</td>';
print '<td align="left">'.$obj->code_compta.'&nbsp;</td>';
@ -242,7 +242,7 @@ if ($result)
print '<td align="center">';
if (defined("MAIN_MODULE_DOSSIER") && MAIN_MODULE_DOSSIER == 1)
{
print '<a href="'.DOL_URL_ROOT.'/dossier/client/fiche.php?id='.$obj->idp.'">';
print '<a href="'.DOL_URL_ROOT.'/dossier/client/fiche.php?id='.$obj->rowid.'">';
print img_folder();
print '</a>';
}

View File

@ -55,17 +55,17 @@ $langs->load('companies');
llxHeader();
$sql = "SELECT s.nom, s.idp,";
$sql = "SELECT s.nom, s.rowid as socid,";
$sql.= " c.rowid, c.ref, c.total_ht,".$db->pdate("c.date_commande")." as date_commande,";
$sql.= " c.fk_statut, c.facture";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.idp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " WHERE c.fk_soc = s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
if ($_GET["month"] > 0)
{
@ -130,7 +130,7 @@ if ($resql)
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"".$link."?id=$objp->rowid\">".img_object($langs->trans("ShowOrder"),"order")." ".$objp->ref."</a></td>\n";
print "<td><a href=\"".DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp."\">".img_object($langs->trans("ShowCompany"),"company")." ".$objp->nom."</a>";
print "<td><a href=\"".DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid."\">".img_object($langs->trans("ShowCompany"),"company")." ".$objp->nom."</a>";
if (($objp->date_commande < (time() - $conf->commande->traitement->warning_delay)) && $objp->statutid == 1 )
{
print img_warning();

View File

@ -60,18 +60,18 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
$sql = "SELECT s.nom, s.idp,"; // Ou
$sql = "SELECT s.nom, s.rowid as socid,"; // Ou
$sql.= " d.rowid, ".$db->pdate("d.dated")." as dd, d.km, "; // Comment
$sql.= " u.name, u.firstname"; // Qui
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE d.fk_soc = s.idp AND d.fk_user = u.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE d.fk_soc = s.rowid AND d.fk_user = u.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1 ,$offset);
@ -98,7 +98,7 @@ if ($resql)
{
$objp = $db->fetch_object($resql);
$soc = new Societe($db);
$soc->fetch($objp->idp);
$soc->fetch($objp->socid);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowTrip"),"trip").' '.$objp->rowid.'</a></td>';

View File

@ -82,7 +82,7 @@ class ComptaJournalPaiement {
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE p.fk_paiement = c.id";
$sql .= " AND pf.fk_paiement = p.rowid";
$sql .= " AND f.fk_soc = s.idp";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND p.statut = 1 ";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND p.fk_export_compta = ".$excid;

View File

@ -79,7 +79,7 @@ class ComptaJournalVente {
$sql .= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c";
$sql .= " WHERE f.rowid = l.fk_facture ";
$sql .= " AND s.idp = f.fk_soc";
$sql .= " AND s.rowid = f.fk_soc";
$sql .= " AND f.fk_statut = 1 ";
$sql .= " AND l.fk_code_ventilation <> 0 ";
$sql .= " AND l.fk_export_compta <> 0";

View File

@ -64,7 +64,7 @@ class ComptaExport
$sql = "SELECT f.rowid as facid, f.facnumber, ".$this->db->pdate("f.datef")." as datef";
$sql .= " , f.total_ttc, f.tva ";
$sql .= " ,s.nom, s.idp, s.code_compta";
$sql .= " ,s.nom, s.rowid as socid, s.code_compta";
$sql .= " , l.price, l.tva_taux";
$sql .= " , c.numero, f.increment";
$sql .= " , l.rowid as lrowid";
@ -75,7 +75,7 @@ class ComptaExport
$sql .= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c";
$sql .= " WHERE f.rowid = l.fk_facture ";
$sql .= " AND s.idp = f.fk_soc";
$sql .= " AND s.rowid = f.fk_soc";
$sql .= " AND f.fk_statut = 1 ";
$sql .= " AND l.fk_code_ventilation <> 0 ";
@ -114,7 +114,7 @@ class ComptaExport
if ($obj->code_compta == '')
{
$societe=new Societe($this->db);
$societe->fetch($obj->idp);
$societe->fetch($obj->socid);
$this->error_message.= $langs->transnoentities("ErrorWrongAccountancyCodeForCompany",$societe->getNomUrl(1))."<br>";
$error++;
}
@ -153,7 +153,7 @@ class ComptaExport
$sql .= " AND p.rowid = pf.fk_paiement";
$sql .= " AND cp.id = p.fk_paiement";
$sql .= " AND f.rowid = pf.fk_facture";
$sql .= " AND f.fk_soc = s.idp";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND p.statut = 1 ";
$sql .= " ORDER BY f.rowid ASC, p.rowid ASC";

View File

@ -2996,14 +2996,14 @@ else
$sql.= ' f.rowid as facid, f.facnumber, f.type, f.increment, f.total, f.total_ttc,';
$sql.= ' '.$db->pdate('f.datef').' as df, '.$db->pdate('f.date_lim_reglement').' as datelimite,';
$sql.= ' f.paye as paye, f.fk_statut,';
$sql.= ' s.nom, s.idp';
$sql.= ' s.nom, s.rowid as socid';
if (! $sall) $sql.= ' ,sum(pf.amount) as am';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
$sql.= ','.MAIN_DB_PREFIX.'facture as f';
if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture ';
if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON f.rowid=fd.fk_facture ';
$sql.= ' WHERE f.fk_soc = s.idp';
if ($socid) $sql .= ' AND s.idp = '.$socid;
$sql.= ' WHERE f.fk_soc = s.rowid';
if ($socid) $sql .= ' AND s.rowid = '.$socid;
if ($month > 0) $sql .= ' AND date_format(f.datef, \'%m\') = '.$month;
if ($_GET['filtre'])
{
@ -3131,7 +3131,7 @@ else
{
print '<td align="center"><b>!!!</b></td>';
}
print '<td><a href="fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans('ShowCompany'),'company').' '.dolibarr_trunc($objp->nom,48).'</a></td>';
print '<td><a href="fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'),'company').' '.dolibarr_trunc($objp->nom,48).'</a></td>';
print '<td align="right">'.price($objp->total).'</td>';
print '<td align="right">'.price($objp->total_ttc).'</td>';
print '<td align="right">'.price($objp->am).'</td>';

View File

@ -410,11 +410,12 @@ else
if ($user->rights->facture->lire)
{
$sql = "SELECT s.nom,s.idp,f.titre,f.total,f.rowid as facid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f WHERE f.fk_soc = s.idp";
$sql = "SELECT s.nom, s.rowid as socid, f.titre, f.total, f.rowid as facid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
$sql.= " WHERE f.fk_soc = s.rowid";
if ($socid)
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
// $sql .= $db->plimit($limit + 1,$offset);
@ -447,7 +448,7 @@ else
print '<td><a href="fiche-rec.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
print "</a></td>\n";
print '<td><a href="../fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
print '<td><a href="../fiche.php?socid='.$objp->socid.'">'.$objp->nom.'</a></td>';
print "<td align=\"right\">".price($objp->total)."</td>\n";

View File

@ -72,20 +72,20 @@ if ($user->rights->facture->lire)
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$sql = "SELECT s.nom, s.idp,";
$sql.= " f.facnumber,f.increment,f.total as total_ht,f.total_ttc,";
$sql.= $db->pdate("f.datef")." as df, ".$db->pdate("f.date_lim_reglement")." as datelimite, ";
$sql.= " f.paye as paye, f.rowid as facid, f.fk_statut";
$sql.= " ,sum(pf.amount) as am";
$sql = "SELECT s.nom, s.rowid as socid";
$sql.= ", f.facnumber,f.increment,f.total as total_ht,f.total_ttc";
$sql.= ", ".$db->pdate("f.datef")." as df, ".$db->pdate("f.date_lim_reglement")." as datelimite";
$sql.= ", f.paye as paye, f.rowid as facid, f.fk_statut";
$sql.= ", sum(pf.amount) as am";
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ",".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
$sql.= " WHERE f.fk_soc = s.idp";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.paye = 0 AND f.fk_statut = 1";
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.idp = ".$socid;
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
if ($_GET["filtre"])
{
@ -205,7 +205,7 @@ if ($user->rights->facture->lire)
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->df)."</td>\n";
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->datelimite)."</td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,32).'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,32).'</a></td>';
print "<td align=\"right\">".price($objp->total_ht)."</td>";
print "<td align=\"right\">".price($objp->total_ttc)."</td>";

View File

@ -73,7 +73,7 @@ if ($mode == 'search')
{
if ($mode-search == 'soc')
{
$sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s ";
$sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s ";
$sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'";
}
@ -82,7 +82,7 @@ if ($mode == 'search')
if ( $db->num_rows() == 1)
{
$obj = $db->fetch_object();
$socid = $obj->idp;
$socid = $obj->rowid;
}
$db->free();
}
@ -109,7 +109,7 @@ $contactstatic = new Contact($db);
if ($socid > 0)
{
$societe = new Societe($db);
$societe->fetch($socid, $to); // si $to='next' ajouter " AND s.idp > $socid ORDER BY idp ASC LIMIT 1";
$societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1";
if ($societe->id <= 0)
{
dolibarr_print_error($db,$societe->error);
@ -242,14 +242,14 @@ if ($socid > 0)
print '<table class="noborder" width="100%">';
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
$sql.= ' '.$db->pdate("f.datef").' as df, f.paye as paye, f.fk_statut as statut,';
$sql.= ' s.nom, s.idp,';
$sql.= ' sum(pf.amount) as am';
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc';
$sql.= ', '.$db->pdate("f.datef").' as df, f.paye as paye, f.fk_statut as statut';
$sql.= ', s.nom, s.rowid as socid';
$sql.= ', sum(pf.amount) as am';
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
$sql.= " WHERE f.fk_soc = s.idp AND s.idp = ".$societe->id;
$sql.= ' GROUP BY f.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
$sql.= ' GROUP BY f.rowid';
$sql.= " ORDER BY f.datef DESC, f.datec DESC";
$resql=$db->query($sql);
@ -392,7 +392,7 @@ if ($socid > 0)
print '<td>&nbsp;</td>';
print "</tr>";
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note";
$sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql.= " WHERE p.fk_soc = ".$societe->id;
$sql.= " ORDER by p.datec";
@ -408,7 +408,7 @@ if ($socid > 0)
print "<tr $bc[$var]>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->idp.'">'.img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.'</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.'</a>&nbsp;';
if (trim($obj->note))
{
@ -416,15 +416,15 @@ if ($socid > 0)
}
print '</td>';
print '<td>'.$obj->poste.'&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->phone.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_FAX&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->fax.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->email.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->phone.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_FAX&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->fax.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->email.'</a>&nbsp;</td>';
print '<td align="center">';
if ($user->rights->societe->contact->creer)
{
print "<a href=\"../contact/fiche.php?action=edit&amp;id=$obj->idp\">";
print "<a href=\"../contact/fiche.php?action=edit&amp;id=".$obj->rowid."\">";
print img_edit();
print '</a>';
}
@ -432,7 +432,7 @@ if ($socid > 0)
print '</td>';
print '<td align="center"><a href="../comm/action/fiche.php?action=create&actioncode=AC_RDV&contactid='.$obj->idp.'&socid='.$societe->id.'">';
print '<td align="center"><a href="../comm/action/fiche.php?action=create&actioncode=AC_RDV&contactid='.$obj->rowid.'&socid='.$societe->id.'">';
print img_object($langs->trans("Rendez-Vous"),"action");
print '</a></td>';

View File

@ -122,12 +122,12 @@ if ($conf->facture->enabled)
if ($conf->facture->enabled && $user->rights->facture->lire)
{
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type,";
$sql.= " s.nom, s.idp";
$sql.= " s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
@ -160,7 +160,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
print $facturestatic->getNomUrl(1,'');
print '</td>';
print '<td>';
$companystatic->id=$obj->idp;
$companystatic->id=$obj->socid;
$companystatic->nom=$obj->nom;
$companystatic->client=1;
print $companystatic->getNomUrl(1,'',16);
@ -245,9 +245,9 @@ if ($conf->tax->enabled)
/**
* Bookmark
*/
$sql = "SELECT s.idp, s.nom,b.rowid as bid";
$sql = "SELECT s.rowid as socid, s.nom, b.rowid as bid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b";
$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id;
$sql .= " WHERE b.fk_soc = s.rowid AND b.fk_user = ".$user->id;
$sql .= " ORDER BY lower(s.nom) ASC";
$resql = $db->query($sql);
@ -266,7 +266,7 @@ if ( $resql )
$obj = $db->fetch_object($resql);
$var = !$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.$obj->nom.'</a></td>';
print '<td align="right"><a href="index.php?action=del_bookmark&amp;bid='.$obj->bid.'">'.img_delete().'</a></td>';
print '</tr>';
$i++;
@ -290,15 +290,15 @@ if ($user->rights->societe->lire)
$langs->load("boxes");
$max=5;
$sql = "SELECT s.nom, s.idp, ".$db->pdate("s.datec")." as dc";
$sql = "SELECT s.nom, s.rowid, ".$db->pdate("s.datec")." as dc";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.client = 1";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($user->societe_id > 0)
{
$sql .= " AND s.idp = $user->societe_id";
$sql .= " AND s.rowid = ".$user->societe_id;
}
$sql .= " ORDER BY s.datec DESC ";
$sql .= $db->plimit($max, 0);
@ -325,7 +325,7 @@ if ($user->rights->societe->lire)
while ($i < $num && $i < $max)
{
$objp = $db->fetch_object($result);
$customerstatic->id=$objp->idp;
$customerstatic->id=$objp->rowid;
$customerstatic->nom=$objp->nom;
$var=!$var;
print '<tr '.$bc[$var].'>';
@ -348,15 +348,15 @@ if ($user->rights->societe->lire)
$langs->load("boxes");
$max=5;
$sql = "SELECT s.nom, s.idp, ".$db->pdate("s.datec")." as dc";
$sql = "SELECT s.nom, s.rowid, ".$db->pdate("s.datec")." as dc";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.fournisseur = 1";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($user->societe_id > 0)
{
$sql .= " AND s.idp = $user->societe_id";
$sql .= " AND s.rowid = ".$user->societe_id;
}
$sql .= " ORDER BY s.datec DESC ";
$sql .= $db->plimit($max, 0);
@ -383,7 +383,7 @@ if ($user->rights->societe->lire)
while ($i < $num && $i < $max)
{
$objp = $db->fetch_object($result);
$customerstatic->id=$objp->idp;
$customerstatic->id=$objp->rowid;
$customerstatic->nom=$objp->nom;
$var=!$var;
print '<tr '.$bc[$var].'>';
@ -408,7 +408,7 @@ if ($conf->facture->enabled && $conf->commande->enabled && $user->rights->comman
$langs->load("orders");
$sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc,";
$sql.= " s.nom, s.idp,";
$sql.= " s.nom, s.rowid as socid,";
$sql.= " p.rowid, p.ref, p.facture, p.fk_statut, p.total_ht, p.total_ttc";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM (".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."commande AS p";
@ -416,11 +416,11 @@ if ($conf->facture->enabled && $conf->commande->enabled && $user->rights->comman
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_fa AS co_fa ON co_fa.fk_commande = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON co_fa.fk_facture = f.rowid";
$sql.= " WHERE p.fk_soc = s.idp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE p.fk_soc = s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql.= " AND p.fk_soc = $socid";
$sql.= " AND p.fk_soc = ".$socid;
}
$sql.= " AND p.fk_statut = 3 AND p.facture=0";
$sql.= " GROUP BY p.rowid";
@ -451,8 +451,8 @@ if ($conf->facture->enabled && $conf->commande->enabled && $user->rights->comman
print "<td width=\"20%\"><a href=\"commande/fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").'</a>&nbsp;';
print "<a href=\"commande/fiche.php?id=$obj->rowid\">".$obj->ref.'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a>&nbsp;';
print '<a href="fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,44).'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").'</a>&nbsp;';
print '<a href="fiche.php?socid='.$obj->socid.'">'.dolibarr_trunc($obj->nom,44).'</a></td>';
if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print '<td align="right">'.price($obj->total_ht).'</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>';
print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td>';
@ -492,15 +492,15 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
$sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.total_ttc, ";
$sql.= $db->pdate("f.date_lim_reglement")." as datelimite,";
$sql.= " sum(pf.amount) as am,";
$sql.= " s.nom, s.idp";
$sql.= " s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.total, f.total_ttc, s.nom, s.idp";
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.total, f.total_ttc, s.nom, s.rowid";
$sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
$resql = $db->query($sql);
@ -533,7 +533,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
print $facturestatic->getNomUrl(1,'');
if ($obj->datelimite < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
print '</td>';
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>';
if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print '<td align="right">'.price($obj->total).'</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>';
print '<td align="right">'.price($obj->am).'</td>';
@ -574,15 +574,15 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
{
$sql = "SELECT ff.rowid, ff.facnumber, ff.fk_statut, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_ttc,";
$sql.= " sum(pf.amount) as am,";
$sql.= " s.nom, s.idp";
$sql.= " s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.idp = ff.fk_soc";
$sql.= " WHERE s.rowid = ff.fk_soc";
$sql.= " AND ff.paye=0 AND ff.fk_statut = 1";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.total, ff.total_ttc, s.nom, s.idp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " GROUP BY ff.rowid, ff.facnumber, ff.fk_statut, ff.total, ff.total_ttc, s.nom, s.rowid";
$resql=$db->query($sql);
if ($resql)
@ -609,7 +609,7 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
$facstatic->id=$obj->rowid;
print $facstatic->getNomUrl(1,'');
print '</td>';
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>';
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>';
if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print '<td align="right">'.price($obj->total_ht).'</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>';
print '<td align="right">'.price($obj->am).'</td>';

View File

@ -205,9 +205,9 @@ print '</table>';
*
*/
$allow_delete = 1 ;
$sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.idp';
$sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
$sql .= ' WHERE pf.fk_facture = f.rowid AND f.fk_soc = s.idp';
$sql .= ' WHERE pf.fk_facture = f.rowid AND f.fk_soc = s.rowid';
$sql .= ' AND pf.fk_paiement = '.$paiement->id;
$resql=$db->query($sql);
if ($resql)
@ -239,7 +239,7 @@ if ($resql)
print $objp->facnumber;
print "</a></td>\n";
print '<td align="center">'.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
print '<td align="right">'.price($objp->amount).'</td>';
print "</tr>\n";
if ($objp->paye == 1)

View File

@ -163,10 +163,10 @@ else
* Factures en attente de prélèvement
*
*/
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp";
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " WHERE s.idp = f.fk_soc";
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
if ($socid)
@ -191,7 +191,7 @@ if ( $db->query($sql) )
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print '<a href="'.DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$obj->rowid.'">'.img_file().' '.$obj->facnumber.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.'</a></td>';
print '</tr>';
$i++;
}

View File

@ -63,15 +63,15 @@ if (! $sortfield) $sortfield="f.facnumber";
*
*/
$sql= "SELECT f.facnumber, f.rowid, s.nom, s.idp";
$sql= "SELECT f.facnumber, f.rowid, s.nom, s.rowid as socid";
$sql.= " , ".$db->pdate("pfd.date_demande")." as date_demande";
$sql.= " , pfd.fk_user_demande";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
$sql.= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.idp = f.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE s.rowid = f.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (! $statut) $sql.= " AND pfd.traite = 0";
if ($statut) $sql.= " AND pfd.traite = ".$statut;
$sql.= " AND pfd.fk_facture = f.rowid";
@ -126,7 +126,7 @@ else
// Ref facture
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$obj->rowid.'">'.img_file().' '.$obj->facnumber.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.'</a></td>';
print '<td align="center">'.dolibarr_print_date($obj->date_demande).'</td>';

View File

@ -97,7 +97,7 @@ $offset = $conf->liste_limit * $page ;
*/
$sql = "SELECT pf.rowid";
$sql .= " ,f.rowid as facid, f.facnumber as ref, f.total_ttc";
$sql .= " , s.idp, s.nom";
$sql .= " , s.rowid as socid, s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf";
@ -105,7 +105,7 @@ $sql .= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.idp";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND pf.fk_facture = f.rowid";
if ($_GET["id"])
{
@ -114,7 +114,7 @@ if ($_GET["id"])
if ($_GET["socid"])
{
$sql .= " AND s.idp = ".$_GET["socid"];
$sql .= " AND s.rowid = ".$_GET["socid"];
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
@ -154,7 +154,7 @@ if ($result)
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->facid.'">'.$obj->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->socid.'">';
print img_object($langs->trans("ShowCompany"),"company"). ' '.stripslashes($obj->nom)."</a></td>\n";
print '<td align="center">'.price($obj->total_ttc)."</td>\n";

View File

@ -77,19 +77,19 @@ if ($sortfield == "") {
*/
$sql = "SELECT p.rowid, pf.statut, p.ref";
$sql .= " ,f.rowid as facid, f.facnumber, f.total_ttc";
$sql .= " , s.idp, s.nom";
$sql .= " , s.rowid as socid, s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement = p.rowid";
$sql .= " AND f.fk_soc = s.idp";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND pf.statut = 2 ";
if ($_GET["socid"])
{
$sql .= " AND s.idp = ".$_GET["socid"];
$sql .= " AND s.rowid = ".$_GET["socid"];
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
@ -131,7 +131,7 @@ if ($result)
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->facid.'">'.$obj->facnumber."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">'.stripslashes($obj->nom)."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->socid.'">'.stripslashes($obj->nom)."</a></td>\n";
print '<td align="center">'.price($obj->total_ttc)."</td>\n";

View File

@ -86,7 +86,7 @@ $rej = new RejetPrelevement($db, $user);
*
*/
$sql = "SELECT pl.rowid, pl.amount, pl.statut";
$sql .= " , s.idp, s.nom";
$sql .= " , s.rowid as socid, s.nom";
$sql .= " , pr.motif, pr.afacturer, pr.fk_facture";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
@ -94,13 +94,13 @@ $sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
$sql .= " WHERE p.rowid=".$prev_id;
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND pl.fk_soc = s.idp";
$sql .= " AND pl.fk_soc = s.rowid";
$sql .= " AND pl.statut = 3 ";
$sql .= " AND pr.fk_prelevement_lignes = pl.rowid";
if ($_GET["socid"])
{
$sql .= " AND s.idp = ".$_GET["socid"];
$sql .= " AND s.rowid = ".$_GET["socid"];
}
$sql .= " ORDER BY pl.amount DESC";
@ -130,7 +130,7 @@ if ($resql)
print substr('000000'.$obj->rowid, -6);
print '</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">'.stripslashes($obj->nom)."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->socid.'">'.stripslashes($obj->nom)."</a></td>\n";
print '<td align="right">'.price($obj->amount)."</td>\n";
print '<td>'.$rej->motifs[$obj->motif].'</td>';

View File

@ -127,15 +127,15 @@ print '</td><td valign="top" width="70%">';
* Factures
*
*/
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp";
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " WHERE s.idp = f.fk_soc";
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
@ -159,7 +159,7 @@ if ( $db->query($sql) )
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print '<a href="'.DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$obj->rowid.'">'.img_file().' '.$obj->facnumber.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$obj->nom.'</a></td>';
print '</tr>';
$i++;
}

View File

@ -195,7 +195,7 @@ if ($_GET["id"])
*/
$sql = "SELECT pf.rowid";
$sql .= " ,f.rowid as facid, f.facnumber as ref, f.total_ttc";
$sql .= " , s.idp, s.nom";
$sql .= " , s.rowid as socid, s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf";
@ -203,13 +203,13 @@ if ($_GET["id"])
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.idp";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND pl.rowid=".$_GET["id"];
if ($_GET["socid"])
{
$sql .= " AND s.idp = ".$_GET["socid"];
$sql .= " AND s.rowid = ".$_GET["socid"];
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
@ -246,7 +246,7 @@ if ($_GET["id"])
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->facid.'">'.$obj->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->socid.'">';
print img_object($langs->trans("ShowCompany"),"company"). ' '.stripslashes($obj->nom)."</a></td>\n";
print '<td align="center">'.price($obj->total_ttc)."</td>\n";

View File

@ -105,15 +105,15 @@ if ($sortfield == "") {
*
*/
$sql = "SELECT pl.rowid, pl.statut, pl.amount";
$sql .= " , s.idp, s.nom";
$sql .= " , s.rowid as socid, s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pl.fk_prelevement_bons=".$prev_id;
$sql .= " AND pl.fk_soc = s.idp";
$sql .= " AND pl.fk_soc = s.rowid";
if ($_GET["socid"])
{
$sql .= " AND s.idp = ".$_GET["socid"];
$sql .= " AND s.rowid = ".$_GET["socid"];
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
@ -151,7 +151,7 @@ if ($result)
print substr('000000'.$obj->rowid, -6);
print '</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">'.stripslashes($obj->nom)."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->socid.'">'.stripslashes($obj->nom)."</a></td>\n";
print '<td align="center">'.price($obj->amount)."</td>\n";

View File

@ -62,7 +62,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pl.fk_prelevement_bons = p.rowid";
$sql .= " AND s.idp = pl.fk_soc";
$sql .= " AND s.rowid = pl.fk_soc";
if ($_GET["search_ligne"])
{

View File

@ -49,7 +49,7 @@ $offset = $conf->liste_limit * $page ;
*/
$sql = "SELECT p.rowid, p.ref, p.statut";
$sql .= " ,f.rowid as facid, f.facnumber, f.total_ttc";
$sql .= " , s.idp, s.nom";
$sql .= " , s.rowid as socid, s.nom";
$sql .= " , pl.statut as statut_ligne, pl.rowid as rowid_ligne";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
@ -58,12 +58,12 @@ $sql .= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.idp";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND pf.fk_facture = f.rowid";
if ($_GET["socid"])
{
$sql .= " AND s.idp = ".$_GET["socid"];
$sql .= " AND s.rowid = ".$_GET["socid"];
}
if ($_GET["search_fac"])
@ -131,7 +131,7 @@ if ($result)
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->facid.'">'.$obj->facnumber."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">';
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->socid.'">';
print img_object($langs->trans("ShowCompany"),"company"). ' '.stripslashes($obj->nom)."</a></td>\n";
print '<td align="right">'.price($obj->total_ttc)."</td>\n";

View File

@ -70,18 +70,18 @@ $rej = new RejetPrelevement($db, $user);
*
*/
$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut";
$sql .= " , s.idp, s.nom";
$sql .= " , s.rowid as socid, s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND pl.fk_soc = s.idp";
$sql .= " AND pl.fk_soc = s.rowid";
if ($_GET["socid"])
{
$sql .= " AND s.idp = ".$_GET["socid"];
$sql .= " AND s.rowid = ".$_GET["socid"];
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
@ -115,7 +115,7 @@ if ($result)
print substr('000000'.$obj->rowid, -6)."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">'.stripslashes($obj->nom)."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->socid.'">'.stripslashes($obj->nom)."</a></td>\n";
print '<td>'.$rej->motifs[$obj->motif].'</td>';
print "</tr>\n";

View File

@ -653,20 +653,20 @@ else
$pagenext = $page + 1;
$sql = "SELECT s.nom, s.idp, s.client,";
$sql = "SELECT s.nom, s.rowid as socid, s.client,";
$sql.= " p.rowid as propalid, p.price, p.ref, p.fk_statut,";
$sql.= $db->pdate("p.datep")." as dp, ";
$sql.= $db->pdate("p.fin_validite")." as dfin";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.idp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.idp = $socid";
$sql.= " WHERE p.fk_soc = s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
if ($viewstatut <> '') $sql .= " AND p.fk_statut in ($viewstatut)"; // viewstatut peut etre combinaisons séparé par virgules
if ($month > 0) $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'";
if ($year > 0) $sql .= " AND date_format(p.datep, '%Y') = $year";
$sql .= " ORDER BY $sortfield $sortorder, p.rowid DESC ";
if ($month > 0) $sql .= " AND date_format(p.datep, '%Y-%m') = '".$year-$month."'";
if ($year > 0) $sql .= " AND date_format(p.datep, '%Y') = ".$year;
$sql .= " ORDER BY ".$sortfield." ".$sortorder.", p.rowid DESC ";
$sql .= $db->plimit($limit + 1,$offset);
if ( $db->query($sql) )
@ -704,7 +704,7 @@ else
// Societe
print "<td>";
$societestatic->nom=$objp->nom;
$societestatic->id=$objp->idp;
$societestatic->id=$objp->socid;
$societestatic->client=$objp->client;
print $societestatic->getNomUrl(1,'customer',44);
print "</td>";

View File

@ -55,7 +55,7 @@ llxHeader();
if ($socid > 0)
{
$societe = new Societe($db);
$societe->fetch($socid, $to); // si $to='next' ajouter " AND s.idp > $socid ORDER BY idp ASC LIMIT 1";
$societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1";
/*
* Affichage onglets
@ -91,11 +91,11 @@ if ($socid > 0)
print '<table class="noborder" width="100%">';
$sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df,";
$sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df,";
$sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql.= " u.login, u.rowid as userid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE f.fk_soc = s.idp AND s.idp = ".$societe->id;
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
$sql.= " AND f.fk_user_valid = u.rowid";
$sql.= " ORDER BY f.datef DESC";

View File

@ -85,18 +85,18 @@ print '<tr><td colspan="4">&nbsp;</td></tr>';
print '<tr><td colspan="4">Facturation clients</td></tr>';
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT s.nom, s.idp, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc";
$sql = "SELECT s.nom, s.rowid as socid, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut in (1,2)";
$sql .= " WHERE f.fk_soc = s.rowid AND f.fk_statut in (1,2)";
if ($year) $sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
} else {
/*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
* vieilles versions, ils n'étaient pas liés via paiement_facture. On les ajoute plus loin)
*/
$sql = "SELECT s.nom as nom, s.idp as idp, sum(pf.amount) as amount_ttc";
$sql = "SELECT s.nom as nom, s.rowid as socid, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
$sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = s.idp";
$sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = s.rowid";
if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
}
if ($socid) $sql .= " AND f.fk_soc = $socid";
@ -114,7 +114,7 @@ if ($result) {
$var=!$var;
print "<tr $bc[$var]><td>&nbsp;</td>";
print "<td>".$langs->trans("Bills")." <a href=\"../facture.php?socid=$objp->idp\">$objp->nom</td>\n";
print "<td>".$langs->trans("Bills")." <a href=\"../facture.php?socid=".$objp->socid."\">$objp->nom</td>\n";
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
print "<td align=\"right\">".price($objp->amount_ttc)."</td>\n";
@ -187,19 +187,19 @@ print '</tr>';
*/
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT s.nom, s.idp, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
$sql = "SELECT s.nom, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut in (1,2)";
$sql .= " WHERE f.fk_soc = s.rowid AND f.fk_statut in (1,2)";
if ($year) {
$sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
}
} else {
$sql = "SELECT s.nom, s.idp, date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc";
$sql = "SELECT s.nom, s.rowid as socid, date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " ON pf.fk_facturefourn = f.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s";
$sql .= " ON f.fk_soc = s.idp";
$sql .= " ON f.fk_soc = s.rowid";
$sql .= " WHERE p.rowid = pf.fk_paiementfourn ";
if ($year) {
$sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
@ -207,10 +207,10 @@ if ($modecompta == 'CREANCES-DETTES')
}
if ($socid)
{
$sql .= " AND f.fk_soc = $socid";
$sql .= " AND f.fk_soc = ".$socid;
}
$sql .= " GROUP BY nom, idp";
$sql .= " ORDER BY nom, idp";
$sql .= " GROUP BY nom, s.rowid";
$sql .= " ORDER BY nom, s.rowid";
print '<tr><td colspan="4">Facturation fournisseurs</td></tr>';
$subtotal_ht = 0;
@ -226,7 +226,7 @@ if ($result) {
$var=!$var;
print "<tr $bc[$var]><td>&nbsp;</td>";
print "<td>".$langs->trans("Bills")." <a href=\"../../fourn/facture/index.php?socid=".$objp->idp."\">$objp->nom</a></td>\n";
print "<td>".$langs->trans("Bills")." <a href=\"".DOL_URL_ROOT."/fourn/facture/index.php?socid=".$objp->socid."\">".$objp->nom."</a></td>\n";
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price(-$objp->amount_ht)."</td>\n";
print "<td align=\"right\">".price(-$objp->amount_ttc)."</td>\n";

View File

@ -84,7 +84,7 @@ $html->report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut in (1,2)";
$sql .= " WHERE f.fk_soc = s.rowid AND f.fk_statut in (1,2)";
} else {
/*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
@ -151,7 +151,7 @@ if ($modecompta != 'CREANCES-DETTES') {
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_soc = s.idp AND f.fk_statut in (1,2)";
$sql .= " WHERE f.fk_soc = s.rowid AND f.fk_statut in (1,2)";
} else {
$sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";

View File

@ -76,9 +76,9 @@ $html->report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$
$catotal=0;
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT s.idp as rowid, s.nom as name, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
$sql = "SELECT s.rowid as socid, s.nom as name, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut in (1,2) AND f.fk_soc = s.idp";
$sql .= " WHERE f.fk_statut in (1,2) AND f.fk_soc = s.rowid";
if ($year) $sql .= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
}
else
@ -87,14 +87,14 @@ else
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
* vieilles versions, ils n'étaient pas liés via paiement_facture. On les ajoute plus loin)
*/
$sql = "SELECT s.idp as rowid, s.nom as name, sum(pf.amount) as amount_ttc";
$sql = "SELECT s.rowid as socid, s.nom as name, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
$sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = s.idp";
$sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = s.rowid";
if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
}
if ($socid) $sql .= " AND f.fk_soc = $socid";
$sql .= " GROUP BY rowid";
$sql .= " ORDER BY rowid";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY s.rowid";
$result = $db->query($sql);
if ($result)
@ -104,8 +104,8 @@ if ($result)
while ($i < $num)
{
$obj = $db->fetch_object($result);
$amount[$obj->rowid] += $obj->amount_ttc;
$name[$obj->rowid] = $obj->name;
$amount[$obj->socid] += $obj->amount_ttc;
$name[$obj->socid] = $obj->name;
$catotal+=$obj->amount_ttc;
$i++;
}

View File

@ -26,11 +26,12 @@ require("./lib.inc.php");
function propals ($db, $year, $month) {
global $bc,$langs;
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id";
$sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
$sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
$sql .= " AND c.id in (1,2,4)";
$sql .= " AND date_format(p.datep, '%Y') = $year ";
$sql .= " AND round(date_format(p.datep, '%m')) = $month ";
$sql .= " AND date_format(p.datep, '%Y') = ".$year;
$sql .= " AND round(date_format(p.datep, '%m')) = ".$month;
$sql .= " ORDER BY p.fk_statut";
@ -68,14 +69,14 @@ function propals ($db, $year, $month) {
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"comp.php?socid=$objp->idp\">$objp->nom</a></td>\n";
print "<td><a href=\"comp.php?socid=".$objp->socid."\">".$objp->nom."</a></td>\n";
print "<td><a href=\"../../comm/propal.php?propalid=$objp->propalid\">$objp->ref</a></td>\n";
print "<td><a href=\"".DOL_URL_ROOT."/comm/propal.php?propalid=".$objp->propalid."\">".$objp->ref."</a></td>\n";
print "<td align=\"right\">".dolibarr_print_date($objp->dp)."</td>\n";
print "<td align=\"right\">".price($objp->price)."</td>\n";
print "<td align=\"center\">$objp->statut</td>\n";
print "<td align=\"center\">".$objp->statut."</td>\n";
print "</tr>\n";
$total = $total + $objp->price;
@ -97,15 +98,15 @@ function propals ($db, $year, $month) {
function factures ($db, $year, $month, $paye) {
global $bc,$conf;
$sql = "SELECT s.nom, s.idp, f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid ";
$sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.fk_statut = 1";
if ($conf->compta->mode != 'CREANCES-DETTES') {
$sql .= " AND f.paye = $paye";
$sql .= " AND f.paye = ".$paye;
}
$sql .= " AND f.fk_soc = s.idp";
$sql .= " AND date_format(f.datef, '%Y') = $year ";
$sql .= " AND round(date_format(f.datef, '%m')) = $month ";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND date_format(f.datef, '%Y') = ".$year;
$sql .= " AND round(date_format(f.datef, '%m')) = ".$month;
$sql .= " ORDER BY f.datef DESC ";
$result = $db->query($sql);
@ -130,8 +131,8 @@ function factures ($db, $year, $month, $paye) {
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"comp.php?socid=$objp->idp\">$objp->nom</a></td>\n";
print "<td><a href=\"../facture.php?facid=$objp->facid\">$objp->facnumber</a></td>\n";
print "<td><a href=\"comp.php?socid=".$objp->socid."\">".$objp->nom."</a></td>\n";
print "<td><a href=\"../facture.php?facid=".$objp->facid."\">".$objp->facnumber."</a></td>\n";
if ($objp->df > 0 )
{
print "<td align=\"right\">".dolibarr_print_date($objp->df)."</td>\n";

View File

@ -49,10 +49,10 @@ function factures ($db, $year, $month, $paye)
{
global $bc,$langs;
$sql = "SELECT s.nom, s.idp, f.facnumber, f.total as amount,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp AND f.paye = $paye";
$sql .= " AND date_format(f.datef, '%Y') = $year ";
$sql .= " AND round(date_format(f.datef, '%m')) = $month ";
$sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.total as amount,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.rowid AND f.paye = ".$paye;
$sql .= " AND date_format(f.datef, '%Y') = ".$year;
$sql .= " AND round(date_format(f.datef, '%m')) = ".$month;
$sql .= " ORDER BY f.datef DESC ";
$result = $db->query($sql);
@ -74,8 +74,8 @@ function factures ($db, $year, $month, $paye)
$objp = $db->fetch_object($result);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"comp.php?socid=$objp->idp\">$objp->nom</a></TD>\n";
print "<TD><a href=\"facture.php?facid=$objp->facid\">$objp->facnumber</a></TD>\n";
print "<TD><a href=\"comp.php?socid=".$objp->socid."\">".$objp->nom."</a></TD>\n";
print "<TD><a href=\"facture.php?facid=".$objp->facid."\">".$objp->facnumber."</a></TD>\n";
if ($objp->df > 0 ) {
print "<TD align=\"right\">".dolibarr_print_date($objp->df)."</TD>\n";
} else {

View File

@ -305,14 +305,14 @@ if ($modecompta != 'CREANCES-DETTES')
// Factures non réglées
// \todo Y a bug ici. Il faut prendre le reste à payer et non le total des factures non réglèes !
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total_ttc, sum(pf.amount) as am";
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.rowid as socid, f.total_ttc, sum(pf.amount) as am";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
$sql .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
$sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
if ($socid)
{
$sql .= " AND f.fk_soc = $socid";
}
$sql .= " GROUP BY f.facnumber,f.rowid,s.nom, s.idp, f.total_ttc";
$sql .= " GROUP BY f.facnumber,f.rowid,s.nom, s.rowid, f.total_ttc";
if ( $db->query($sql) )
{
@ -352,16 +352,16 @@ if ($modecompta != 'CREANCES-DETTES')
Je commente toute cette partie car les chiffres affichées sont faux - Eldy.
En attendant correction.
$sql = "SELECT sum(f.total) as tot_fht,sum(f.total_ttc) as tot_fttc, p.rowid, p.ref, s.nom, s.idp, p.total_ht, p.total_ttc
$sql = "SELECT sum(f.total) as tot_fht,sum(f.total_ttc) as tot_fttc, p.rowid, p.ref, s.nom, s.rowid as socid, p.total_ht, p.total_ttc
FROM ".MAIN_DB_PREFIX."commande AS p, llx_societe AS s
LEFT JOIN ".MAIN_DB_PREFIX."co_fa AS co_fa ON co_fa.fk_commande = p.rowid
LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON co_fa.fk_facture = f.rowid
WHERE p.fk_soc = s.idp
WHERE p.fk_soc = s.rowid
AND p.fk_statut >=1
AND p.facture =0";
if ($socid)
{
$sql .= " AND f.fk_soc = $socid";
$sql .= " AND f.fk_soc = ".$socid;
}
$sql .= " GROUP BY p.rowid";

View File

@ -62,13 +62,13 @@ function tva_coll($db,$y)
if ($conf->compta->mode == "CREANCES-DETTES")
{
// Si on paye la tva sur les factures dues (non brouillon)
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra, sum(f.total) as amount, sum(f.tva) as tva, s.tva_assuj as assuj, s.idp as id_soc";
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra, sum(f.total) as amount, sum(f.tva) as tva, s.tva_assuj as assuj, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)";
$sql.= " AND date_format(f.datef,'%Y') = ".$y;
$sql.= " AND s.idp = f.fk_soc ";
$sql.= " GROUP BY s.idp";
$sql.= " AND s.rowid = f.fk_soc ";
$sql.= " GROUP BY s.rowid";
}
else
{
@ -120,13 +120,13 @@ function tva_paye($db, $y)
if ($conf->compta->mode == "CREANCES-DETTES")
{
// Si on paye la tva sur les factures dues (non brouillon)
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra, sum(f.total_ht) as amount, sum(f.tva) as tva, s.tva_assuj as assuj, s.idp as id_soc";
$sql = "SELECT s.nom as nom, s.tva_intra as tva_intra, sum(f.total_ht) as amount, sum(f.tva) as tva, s.tva_assuj as assuj, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)";
$sql.= " AND date_format(f.datef,'%Y') = ".$y;
$sql.= " AND s.idp = f.fk_soc ";
$sql.= " GROUP BY s.idp";
$sql.= " AND s.rowid = f.fk_soc ";
$sql.= " GROUP BY s.rowid";
}
else
{

View File

@ -182,7 +182,7 @@ class Contact
$sql .= ", phone_mobile = '".addslashes($this->phone_mobile)."'";
$sql .= ", jabberid = '".addslashes($this->jabberid)."'";
if ($user) $sql .= ", fk_user_modif=".$user->id;
$sql .= " WHERE idp=".$id;
$sql .= " WHERE rowid=".$id;
dolibarr_syslog("Contact.class::update sql=".$sql,LOG_DEBUG);
$result = $this->db->query($sql);
@ -300,7 +300,7 @@ class Contact
function update_perso($id, $user=0)
{
// Mis a jour contact
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET idp=".$id;
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET rowid=".$id;
if ($this->birthday) // <0 si avant 1970, >0 si apres 1970
{
@ -316,7 +316,7 @@ class Contact
}
}
if ($user) $sql .= ", fk_user_modif=".$user->id;
$sql .= " WHERE idp=$id";
$sql .= " WHERE rowid=".$id;
dolibarr_syslog("Contact::update_perso this->birthday=".$this->birthday." - sql=".$sql);
$resql = $this->db->query($sql);
@ -371,7 +371,7 @@ class Contact
{
global $langs;
$langs->load("companies");
$sql = "SELECT c.idp, c.fk_soc, c.civilite as civilite_id, c.name, c.firstname,";
$sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name, c.firstname,";
$sql.= " c.address, c.cp, c.ville,";
$sql.= " c.fk_pays, p.libelle as pays, p.code as pays_code,";
$sql.= " c.birthday,";
@ -379,8 +379,8 @@ class Contact
$sql.= " u.rowid as user_id, u.login as user_login";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON c.fk_pays = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.idp = u.fk_socpeople";
$sql.= " WHERE c.idp = ". $id;
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
$sql.= " WHERE c.rowid = ". $id;
dolibarr_syslog("Contact::fetch sql=".$sql);
$resql=$this->db->query($sql);
@ -390,7 +390,7 @@ class Contact
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->idp;
$this->id = $obj->rowid;
$this->civilite_id = $obj->civilite_id;
$this->name = $obj->name;
$this->firstname = $obj->firstname;
@ -540,7 +540,7 @@ class Contact
global $conf, $langs;
$sql = "SELECT c.name, c.firstname FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql .= " WHERE c.idp = ". $id;
$sql .= " WHERE c.rowid = ". $id;
$resql=$this->db->query($sql);
if ($resql)
{
@ -554,7 +554,7 @@ class Contact
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
$sql .= " WHERE idp=$id";
$sql .= " WHERE rowid=".$id;
$result = $this->db->query($sql);
if (! $result)
@ -580,10 +580,10 @@ class Contact
*/
function info($id)
{
$sql = "SELECT c.idp, ".$this->db->pdate("c.datec")." as datec, c.fk_user_creat";
$sql = "SELECT c.rowid, ".$this->db->pdate("c.datec")." as datec, c.fk_user_creat";
$sql .= ", ".$this->db->pdate("c.tms")." as tms, c.fk_user_modif";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql .= " WHERE c.idp = ".$id;
$sql .= " WHERE c.rowid = ".$id;
$resql=$this->db->query($sql);
if ($resql)
@ -592,7 +592,7 @@ class Contact
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->idp;
$this->id = $obj->rowid;
if ($obj->fk_user_creat) {
$cuser = new User($this->db, $obj->fk_user_creat);
@ -747,7 +747,7 @@ class Contact
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe LIMIT 10";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{

View File

@ -49,7 +49,7 @@ if ($contactid && ! $user->rights->commercial->client->voir)
{
$sql = "SELECT sc.fk_soc, sp.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= " WHERE sp.idp = ".$contactid;
$sql .= " WHERE sp.rowid = ".$contactid;
if (! $user->rights->commercial->client->voir && ! $socid)
{
$sql .= " AND sc.fk_soc = sp.fk_soc AND sc.fk_user = ".$user->id;

View File

@ -58,7 +58,7 @@ if ($contactid && !$user->rights->commercial->client->voir)
{
$sql = "SELECT sc.fk_soc, sp.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= " WHERE sp.idp = ".$contactid;
$sql .= " WHERE sp.rowid = ".$contactid;
if (!$user->rights->commercial->client->voir && !$user->societe_id > 0)
{
$sql .= " AND sc.fk_soc = sp.fk_soc AND sc.fk_user = ".$user->id;

View File

@ -104,13 +104,13 @@ if ($_POST["button_removefilter"])
llxHeader();
$sql = "SELECT s.idp, s.nom, ";
$sql.= " p.idp as cidp, p.name, p.firstname, p.email, p.phone, p.phone_mobile, p.fax";
$sql = "SELECT s.rowid as socid, s.nom, ";
$sql.= " p.rowid as cidp, p.name, p.firstname, p.email, p.phone, p.phone_mobile, p.fax";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= MAIN_DB_PREFIX."societe_commerciaux as sc,";
$sql.= " ".MAIN_DB_PREFIX."socpeople as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = p.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql.= " WHERE 1=1 ";
if ($_GET["userid"]) // statut commercial
@ -119,7 +119,7 @@ if ($_GET["userid"]) // statut commercial
}
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
if ($search_nom) // filtre sur le nom
{
@ -155,7 +155,7 @@ if ($sall)
}
if ($socid)
{
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
if($_GET["view"] == "recent")
@ -261,9 +261,9 @@ if ($result)
print ' '.$obj->name.'</a></td>';
print '<td>'.$obj->firstname.'</td>';
print '<td>';
if ($obj->idp)
if ($obj->socid)
{
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">';
print img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,40).'</a>';
}
else
@ -271,7 +271,7 @@ if ($result)
print '&nbsp;';
}
print '</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;actioncode=AC_TEL&amp;contactid='.$obj->cidp.'&amp;socid='.$obj->idp.'">'.dolibarr_print_phone($obj->phone).'</a>&nbsp;</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;actioncode=AC_TEL&amp;contactid='.$obj->cidp.'&amp;socid='.$obj->socid.'">'.dolibarr_print_phone($obj->phone).'</a>&nbsp;</td>';
if ($_GET["view"] == 'phone')
{

View File

@ -50,7 +50,7 @@ if ($contactid && ! $user->rights->commercial->client->voir)
{
$sql = "SELECT sc.fk_soc, sp.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= " WHERE sp.idp = ".$contactid;
$sql .= " WHERE sp.rowid = ".$contactid;
if (! $user->rights->commercial->client->voir && ! $socid)
{
$sql .= " AND sc.fk_soc = sp.fk_soc AND sc.fk_user = ".$user->id;

View File

@ -51,7 +51,7 @@ if ($contactid && ! $user->rights->commercial->client->voir)
{
$sql = "SELECT sc.fk_soc, sp.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= " WHERE sp.idp = ".$contactid;
$sql .= " WHERE sp.rowid = ".$contactid;
if (! $user->rights->commercial->client->voir && ! $socid)
{
$sql .= " AND sc.fk_soc = sp.fk_soc AND sc.fk_user = ".$user->id;

View File

@ -50,7 +50,7 @@ if ($contactid && ! $user->rights->commercial->client->voir)
{
$sql = "SELECT sc.fk_soc, sp.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= " WHERE sp.idp = ".$contactid;
$sql .= " WHERE sp.rowid = ".$contactid;
if (! $user->rights->commercial->client->voir && ! $socid)
{
$sql .= " AND sc.fk_soc = sp.fk_soc AND sc.fk_user = ".$user->id;

View File

@ -319,9 +319,9 @@ if ($_GET["action"] == 'create')
$new_contrat = new Contrat($db);
$sql = "SELECT s.nom, s.prefix_comm, s.idp ";
$sql .= "FROM ".MAIN_DB_PREFIX."societe as s ";
$sql .= "WHERE s.idp = ".$_GET["socid"];
$sql = "SELECT s.nom, s.prefix_comm, s.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.rowid = ".$_GET["socid"];
$resql=$db->query($sql);
if ($resql)
@ -332,7 +332,7 @@ if ($_GET["action"] == 'create')
$obj = $db->fetch_object($resql);
$soc = new Societe($db);
$soc->fetch($obj->idp);
$soc->fetch($obj->rowid);
print '<form name="contrat" action="fiche.php" method="post">';

View File

@ -105,16 +105,16 @@ $sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
$sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > sysdate()",1,0).') as nb_running,';
$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= sysdate())",1,0).') as nb_late,';
$sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,';
$sql.= " c.rowid as cid, c.ref, c.datec, c.statut, s.nom, s.idp as sidp";
$sql.= " c.rowid as cid, c.ref, c.datec, c.statut, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
$sql.= " ".MAIN_DB_PREFIX."contrat as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql.= " WHERE c.fk_soc = s.idp ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql .= " AND s.idp = ".$socid;
$sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.idp";
$sql.= " WHERE c.fk_soc = s.rowid ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
$sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.rowid";
$sql.= " ORDER BY c.datec DESC";
$sql.= " LIMIT $max";
@ -146,7 +146,7 @@ if ($result)
. (isset($obj->ref) ? $obj->ref : $obj->cid).'</a>';
if ($obj->nb_late) print img_warning($langs->trans("Late"));
print '</td>';
print '<td><a href="../comm/fiche.php?socid='.$obj->sidp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td><a href="../comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
print '<td align="left">'.$staticcontrat->LibStatut($obj->statut,2).'</td>';
print '<td align="center">'.($obj->nb_initial>0?$obj->nb_initial:'').'</td>';
@ -174,9 +174,9 @@ if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, s
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.statut=1 AND cd.statut = 0";
$sql.= " AND cd.fk_contrat = c.rowid AND c.fk_soc = s.idp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND s.idp = ".$socid;
$sql.= " AND cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY cd.tms DESC";
if ( $db->query($sql) )
@ -227,9 +227,9 @@ $sql = "SELECT cd.rowid as cid, c.ref, cd.statut, cd.label, cd.description as no
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.idp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND s.idp = ".$socid;
$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY cd.tms DESC";
if ( $db->query($sql) )

View File

@ -72,18 +72,18 @@ $sql.= ' sum('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
$sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > sysdate()",1,0).') as nb_running,';
$sql.= ' sum('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite <= sysdate())",1,0).') as nb_late,';
$sql.= ' sum('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,';
$sql.= " c.rowid as cid, c.ref, c.datec, c.statut, s.nom, s.idp as sidp";
$sql.= " c.rowid as cid, c.ref, c.datec, c.statut, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql.= " WHERE c.fk_soc = s.idp ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE c.fk_soc = s.rowid ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($search_nom) $sql.= " AND s.nom like '%".addslashes($search_nom)."%'";
if ($search_contract) $sql.= " AND c.rowid = '".addslashes($search_contract)."'";
if ($sall) $sql.= " AND (s.nom like '%".addslashes($sall)."%' OR cd.label like '%".addslashes($sall)."%' OR cd.description like '%".addslashes($sall)."%')";
if ($socid > 0) $sql.= " AND s.idp = ".$socid;
$sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.idp";
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
$sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.rowid";
$sql.= " ORDER BY $sortfield $sortorder";
$sql.= $db->plimit($limit + 1 ,$offset);
@ -135,7 +135,7 @@ if ($resql)
print img_object($langs->trans("ShowContract"),"contract").' '.(isset($obj->ref) ? $obj->ref : $obj->cid) .'</a>';
if ($obj->nb_late) print img_warning($langs->trans("Late"));
print '</td>';
print '<td><a href="../comm/fiche.php?socid='.$obj->sidp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td><a href="../comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
print '<td align="center">'.$staticcontrat->LibStatut($obj->statut,3).'</td>';
print '<td align="center">'.($obj->nb_initial>0?$obj->nb_initial:'').'</td>';

View File

@ -68,7 +68,7 @@ $staticcontratligne=new ContratLigne($db);
llxHeader();
$sql = "SELECT s.idp as sidp, s.nom, c.rowid as cid,";
$sql = "SELECT s.rowid as socid, s.nom, c.rowid as cid,";
$sql.= " cd.rowid, cd.description, cd.statut, p.rowid as pid, p.label as label,";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,";
$sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_ouverture_prevue,";
@ -82,8 +82,8 @@ if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PR
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE c.statut > 0";
$sql.= " AND c.rowid = cd.fk_contrat";
$sql.= " AND c.fk_soc = s.idp";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " AND c.fk_soc = s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($mode == "0") $sql.= " AND cd.statut = 0";
if ($mode == "4") $sql.= " AND cd.statut = 4";
if ($mode == "5") $sql.= " AND cd.statut = 5";
@ -91,7 +91,7 @@ if ($filter == "expired") $sql.= " AND date_fin_validite < sysdate()";
if ($search_nom) $sql.= " AND s.nom like '%".addslashes($search_nom)."%'";
if ($search_contract) $sql.= " AND c.rowid = '".addslashes($search_contract)."'";
if ($search_service) $sql.= " AND (p.ref like '%".addslashes($search_service)."%' OR p.description like '%".addslashes($search_service)."%')";
if ($socid > 0) $sql.= " AND s.idp = ".$socid;
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
$sql .= " ORDER BY $sortfield $sortorder";
$sql .= $db->plimit($limit + 1 ,$offset);
@ -163,7 +163,7 @@ if ($resql)
print dolibarr_trunc($obj->description,20);
}
print '</td>';
print '<td><a href="../comm/fiche.php?socid='.$obj->sidp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>';
print '<td><a href="../comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>';
// Date debut
if ($mode == "0") {
print '<td align="center">';

View File

@ -72,7 +72,7 @@ class pdf_courrier_droit_editeur
$year = strftime("%Y", time());
//
$sql = "SELECT s.idp,s.nom";
$sql = "SELECT s.rowid,s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
//$sql .= " , ".MAIN_DB_PREFIX."categorie_fournisseur as cf";
$sql .= " WHERE s.fournisseur = 1 ";
@ -104,7 +104,7 @@ class pdf_courrier_droit_editeur
while ($obj = $this->db->fetch_object($resql) )
{
$id = $obj->idp;
$id = $obj->rowid;
dolibarr_syslog("droits-editeurs.php id:$id", LOG_DEBUG );
@ -198,15 +198,14 @@ class pdf_courrier_droit_editeur
{
$i = 0;
while ($obj = $this->db->fetch_object($resql) )
{
$id = $obj->idp;
$books[$i]['title'] = $obj->label;
$books[$i]['id'] = $obj->rowid;
$books[$i]['taux'] = $obj->taux;
$books[$i]['qty'] = $obj->quantite;
{
$books[$i]['title'] = $obj->label;
$books[$i]['id'] = $obj->rowid;
$books[$i]['taux'] = $obj->taux;
$books[$i]['qty'] = $obj->quantite;
$i++;
}
$i++;
}
$this->db->free($resql);
}
else

View File

@ -183,7 +183,7 @@ if ($modulepart)
$accessallowed=1;
}
$original_file=$conf->societe->dir_output.'/'.$original_file;
$sqlprotectagainstexternals = "SELECT idp as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE idp='$refname'";
$sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE idp='$refname'";
}
// Wrapping pour les expedition

View File

@ -145,7 +145,7 @@ class Don
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{

View File

@ -660,7 +660,7 @@ class Expedition extends CommonObject
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{

View File

@ -50,18 +50,18 @@ print "</form></table><br />\n";
/*
* Expeditions à valider
*/
$sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id";
$sql = "SELECT e.rowid, e.ref, s.nom, s.rowid as socid, c.ref as commande_ref, c.rowid as commande_id";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.idp AND e.fk_statut = 0";
$sql.= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.rowid AND e.fk_statut = 0";
if ($socid)
{
$sql .= " AND c.fk_soc = $socid";
$sql .= " AND c.fk_soc = ".$socid;
}
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
$resql=$db->query($sql);
if ($resql)
@ -78,8 +78,8 @@ if ($resql)
{
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td nowrap=\"nowrap\"><a href=\"fiche.php?id=$obj->rowid\">".$obj->ref."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
print "<tr $bc[$var]><td nowrap=\"nowrap\"><a href=\"fiche.php?id=".$obj->rowid."\">".$obj->ref."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$obj->commande_id.'">'.$obj->commande_ref.'</a></td></tr>';
$i++;
}
@ -91,13 +91,13 @@ if ($resql)
/*
* Commandes à traiter
*/
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
$sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut = 1";
if ($socid) $sql .= " AND c.fk_soc = $socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE c.fk_soc = s.rowid AND c.fk_statut = 1";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY c.rowid ASC";
if ( $db->query($sql) )
@ -118,8 +118,8 @@ if ( $db->query($sql) )
$obj = $db->fetch_object();
print "<tr $bc[$var]>";
print '<td nowrap="nowrap">';
print "<a href=\"commande.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,20).'</a></td></tr>';
print "<a href=\"commande.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.dolibarr_trunc($obj->nom,20).'</a></td></tr>';
$i++;
}
print "</table><br>";
@ -136,13 +136,13 @@ print '</td><td valign="top" width="70%">';
/*
* Commandes en traitement
*/
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
$sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 2";
if ($socid) $sql .= " AND c.fk_soc = $socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " WHERE c.fk_soc = s.rowid AND c.fk_statut = 2";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$resql = $db->query($sql);
if ( $resql )
{
@ -160,9 +160,9 @@ if ( $resql )
{
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td width=\"30%\"><a href=\"commande.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").' ';
print "<tr $bc[$var]><td width=\"30%\"><a href=\"commande.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowOrder"),"order").' ';
print $obj->ref.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td></tr>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.$obj->nom.'</a></td></tr>';
$i++;
}
print "</table><br>";
@ -173,13 +173,13 @@ if ( $resql )
/*
* Expeditions à valider
*/
$sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id";
$sql = "SELECT e.rowid, e.ref, s.nom, s.rowid as socid, c.ref as commande_ref, c.rowid as commande_id";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.idp AND e.fk_statut = 1";
if ($socid) $sql .= " AND c.fk_soc = $socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.rowid AND e.fk_statut = 1";
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " ORDER BY e.date_expedition DESC";
$sql .= $db->plimit(5, 0);
@ -200,7 +200,7 @@ if ($resql)
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td width=\"20%\"><a href=\"fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowSending"),"sending").' ';
print $obj->ref.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$obj->commande_id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$obj->commande_ref.'</a></td></tr>';
$i++;
}

View File

@ -57,13 +57,13 @@ $offset = $limit * $_GET["page"] ;
llxHeader('',$langs->trans('ListOfSendings'),'ch-expedition.html');
$sql = "SELECT e.rowid, e.ref,".$db->pdate("e.date_expedition")." as date_expedition, e.fk_statut, s.nom as socname, s.idp, c.ref as comref, c.rowid as comid";
$sql = "SELECT e.rowid, e.ref,".$db->pdate("e.date_expedition")." as date_expedition, e.fk_statut, s.nom as socname, s.rowid as socid, c.ref as comref, c.rowid as comid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."commande as c";
if ($socid) $sql.=", ".MAIN_DB_PREFIX."commande as c";
if ($user->rights->commercial->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = e.fk_commande";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = c.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc";
$sql_add = " WHERE ";
if ($socid)
@ -111,9 +111,9 @@ if ($resql)
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$objp->rowid\">".img_object($langs->trans("ShowSending"),"sending").'</a>&nbsp;';
print "<a href=\"fiche.php?id=$objp->rowid\">".$objp->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp.'">'.$objp->socname.'</a></td>';
print "<td><a href=\"fiche.php?id=".$objp->rowid."\">".img_object($langs->trans("ShowSending"),"sending").'</a>&nbsp;';
print "<a href=\"fiche.php?id=".$objp->rowid."\">".$objp->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.$objp->socname.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$objp->comid.'">'.$objp->comref.'</a></td>';
$now = time();

View File

@ -2582,7 +2582,7 @@ class Facture extends CommonObject
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{

View File

@ -65,15 +65,15 @@ if ($user->societe_id > 0)
llxHeader();
$sql = "SELECT s.nom,s.idp, f.ref,".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut, f.note, f.duree";
$sql = "SELECT s.nom,s.rowid as socid, f.ref,".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut, f.note, f.duree";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.fk_soc = s.idp ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " WHERE f.fk_soc = s.rowid ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0)
{
$sql .= " AND s.idp = " . $socid;
$sql .= " AND s.rowid = " . $socid;
}
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit( $limit + 1 ,$offset);
@ -105,8 +105,8 @@ if ($result)
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$objp->fichid\">".img_object($langs->trans("Show"),"task").' '.$objp->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44)."</a></td>\n";
print "<td><a href=\"fiche.php?id=".$objp->fichid."\">".img_object($langs->trans("Show"),"task").' '.$objp->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,44)."</a></td>\n";
print '<td>'.nl2br($objp->note).'</td>';
print '<td align="center">'.dolibarr_print_date($objp->dp)."</td>\n";
print '<td align="right">'.price($objp->duree).'</td>';

View File

@ -52,14 +52,14 @@ $offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$sql = "SELECT s.nom,s.idp, f.note, f.ref,".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut, f.duree";
$sql = "SELECT s.nom,s.rowid as socid, f.note, f.ref,".$db->pdate("f.datei")." as dp, f.rowid as fichid, f.fk_statut, f.duree";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f ";
$sql .= " WHERE f.fk_soc = s.idp";
$sql .= " WHERE f.fk_soc = s.rowid";
if ($socid > 0)
{
$sql .= " AND s.idp = " . $socid;
$sql .= " AND s.rowid = " . $socid;
}
if (empty ($MM))
@ -120,8 +120,8 @@ if ( $db->query($sql) )
{
if (!empty($MM))
$filter="&MM=$MM&YY=$YY";
print '<td><a href="rapport.php?socid='.$objp->idp.$filter.'"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/filter.png" border="0"></a>&nbsp;';
print "<a href=\"../comm/fiche.php?socid=$objp->idp$filter\">$objp->nom</a></TD>\n";
print '<td><a href="rapport.php?socid='.$objp->socid.$filter.'"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/filter.png" border="0"></a>&nbsp;';
print "<a href=\"".DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->rowid.$filter."\">".$objp->nom."</a></TD>\n";
}
print '<td>'.nl2br($objp->note).'</td>';
print "<td>".strftime("%d %B %Y",$objp->dp)."</td>\n";

View File

@ -51,7 +51,7 @@ $sql = "SELECT count(cf.rowid), fk_statut,";
$sql.= " cf.rowid,cf.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,";
$sql.= " ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sql.= " WHERE cf.fk_soc = s.idp ";
$sql.= " WHERE cf.fk_soc = s.rowid ";
$sql.= " GROUP BY cf.fk_statut";
$resql = $db->query($sql);

View File

@ -69,15 +69,15 @@ $offset = $conf->liste_limit * $page ;
* Mode Liste
*/
$sql = "SELECT s.idp, s.nom, ".$db->pdate("cf.date_commande")." as dc,";
$sql = "SELECT s.rowid as socid, s.nom, ".$db->pdate("cf.date_commande")." as dc,";
$sql .= " cf.rowid,cf.ref, cf.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,";
$sql .= " ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sql .= " WHERE cf.fk_soc = s.idp ";
$sql .= " WHERE cf.fk_soc = s.rowid ";
if ($socid)
{
$sql .= " AND s.idp=".$socid;
$sql .= " AND s.rowid = ".$socid;
}
if (strlen($_GET["statut"]))
@ -138,7 +138,7 @@ if ($resql)
print '<td><a href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.'</a></td>'."\n";
// Société
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' ';
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' ';
print $obj->nom.'</a></td>'."\n";
// Date

View File

@ -60,12 +60,12 @@ $offset = $limit * $page ;
*
*/
$sql = "SELECT s.idp, s.nom, st.libelle as stcomm, p.idp as cidp, p.name, p.firstname, p.email, p.phone";
$sql = "SELECT s.rowid as socid, s.nom, st.libelle as stcomm, p.rowid as cidp, p.name, p.firstname, p.email, p.phone";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as p, ".MAIN_DB_PREFIX."c_stcomm as st";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.fk_stcomm = st.id AND s.fournisseur = 1 AND s.idp = p.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql .= " WHERE s.fk_stcomm = st.id AND s.fournisseur = 1 AND s.rowid = p.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (strlen($stcomm)) {
$sql .= " AND s.fk_stcomm=$stcomm";
@ -82,7 +82,7 @@ if ($contactname) {
}
if ($socid) {
$sql .= " AND s.idp = $socid";
$sql .= " AND s.rowid = ".$socid;
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset);
@ -113,7 +113,7 @@ if ($result) {
print '<td><a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'">'.img_object($langs->trans("ShowContact"),"contact").' '.$obj->name.'</a></td>';
print '<td>'.$obj->firstname.'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print '<td>'.$obj->email.'</td>';
print '<td>'.$obj->phone.'</td>';

View File

@ -73,7 +73,7 @@ if ($user->rights->fournisseur->facture->lire)
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$sql = "SELECT s.nom, s.idp,";
$sql = "SELECT s.nom, s.rowid as socid,";
$sql.= " f.facnumber,f.total_ht,f.total_ttc,";
$sql.= $db->pdate("f.datef")." as df, ".$db->pdate("f.date_lim_reglement")." as datelimite, ";
$sql.= " f.paye as paye, f.rowid as facid, f.fk_statut";
@ -83,10 +83,10 @@ if ($user->rights->fournisseur->facture->lire)
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ",".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn ";
$sql.= " WHERE f.fk_soc = s.idp";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.paye = 0 AND f.fk_statut = 1";
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.idp = ".$socid;
if (! $user->rights->commercial->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
if ($_GET["filtre"])
{
@ -206,7 +206,7 @@ if ($user->rights->fournisseur->facture->lire)
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->df)."</td>\n";
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->datelimite)."</td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,32).'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($objp->nom,32).'</a></td>';
print "<td align=\"right\">".price($objp->total_ht)."</td>";
print "<td align=\"right\">".price($objp->total_ttc)."</td>";

View File

@ -64,7 +64,7 @@ if ($_POST["mode"] == 'search')
{
if ($_POST["mode-search"] == 'soc')
{
$sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s ";
$sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s ";
$sql.= " WHERE s.nom like '%".addslashes(strtolower($socname))."%'";
}
@ -73,7 +73,7 @@ if ($_POST["mode"] == 'search')
if ( $db->num_rows() == 1)
{
$obj = $db->fetch_object();
$socid = $obj->idp;
$socid = $obj->rowid;
}
$db->free();
}
@ -89,17 +89,17 @@ if ($_POST["mode"] == 'search')
llxHeader();
$sql = "SELECT s.idp as socid, s.nom, ";
$sql = "SELECT s.rowid as socid, s.nom, ";
$sql.= " ".$db->pdate("fac.datef")." as datef, ".$db->pdate("fac.date_lim_reglement")." as date_echeance,";
$sql.= " fac.total_ht, fac.total_ttc, fac.paye as paye, fac.fk_statut as fk_statut, fac.libelle, fac.rowid as facid, fac.facnumber";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as fac";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE fac.fk_soc = s.idp";
$sql.= " WHERE fac.fk_soc = s.rowid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql .= " AND s.idp = ".$socid;
$sql .= " AND s.rowid = ".$socid;
}
if ($_GET["filtre"])
{

View File

@ -200,13 +200,13 @@ if ($action == 'create' || $action == 'add_paiement')
$facture = new FactureFournisseur($db);
$facture->fetch($facid);
$sql = 'SELECT s.nom,s.idp, f.amount, f.total_ttc as total, f.facnumber';
$sql = 'SELECT s.nom, s.rowid as socid, f.amount, f.total_ttc as total, f.facnumber';
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ' WHERE f.fk_soc = s.idp';
$sql .= ' WHERE f.fk_soc = s.rowid';
$sql .= ' AND f.rowid = '.$facid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$resql = $db->query($sql);
if ($resql)
{
@ -221,7 +221,7 @@ if ($action == 'create' || $action == 'add_paiement')
print '<input type="hidden" name="action" value="add_paiement">';
print '<input type="hidden" name="facid" value="'.$facid.'">';
print '<input type="hidden" name="facnumber" value="'.$obj->facnumber.'">';
print '<input type="hidden" name="socid" value="'.$obj->idp.'">';
print '<input type="hidden" name="socid" value="'.$obj->socid.'">';
print '<input type="hidden" name="societe" value="'.$obj->nom.'">';
print '<table class="border" width="100%">';
@ -355,7 +355,7 @@ if (! $_GET['action'] && ! $_POST['action'])
$sql = 'SELECT p.rowid, '.$db->pdate('p.datep').' as dp, p.amount as pamount,';
$sql.= ' f.amount, f.facnumber, f.rowid as facid,';
$sql.= ' s.idp, s.nom,';
$sql.= ' s.rowid as socid, s.nom,';
$sql.= ' c.libelle as paiement_type, p.num_paiement,';
$sql.= ' ba.rowid as bid, ba.label';
if (!$user->rights->commercial->client->voir) $sql .= ", sc.fk_soc, sc.fk_user ";
@ -364,10 +364,10 @@ if (! $_GET['action'] && ! $_POST['action'])
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn ';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.idp = f.fk_soc';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
if (!$user->rights->commercial->client->voir) $sql .= " WHERE s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir) $sql .= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql .= ' WHERE f.fk_soc = '.$socid;
@ -406,7 +406,7 @@ if (! $_GET['action'] && ! $_POST['action'])
else print '&nbsp;';
print '</td>';
print '<td>';
if ($objp->idp) print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$objp->idp.'">'.img_object($langs->trans('ShowCompany'),'company').' '.dolibarr_trunc($objp->nom,32).'</a>';
if ($objp->socid) print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'),'company').' '.dolibarr_trunc($objp->nom,32).'</a>';
else print '&nbsp;';
print '</td>';
print '<td nowrap="nowrap" align="center">'.dolibarr_print_date($objp->dp)."</td>\n";

View File

@ -343,7 +343,7 @@ class PaiementFourn
if ($num)
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->idp;
$this->id = $obj->rowid;
if ($obj->fk_user_creat)
{
$cuser = new User($this->db, $obj->fk_user_creat);

View File

@ -59,7 +59,7 @@ if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0
{
$sql = "SELECT sc.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.idp AND sc.fk_user = ".$user->id." AND s.fournisseur = 1";
$sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.rowid AND sc.fk_user = ".$user->id." AND s.fournisseur = 1";
if ( $db->query($sql) )
{

View File

@ -59,7 +59,7 @@ if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0
{
$sql = "SELECT sc.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.idp AND sc.fk_user = ".$user->id." AND s.fournisseur = 1";
$sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.rowid AND sc.fk_user = ".$user->id." AND s.fournisseur = 1";
if ( $db->query($sql) )
{
@ -311,7 +311,7 @@ if ( $societe->fetch($socid) )
print '<td>&nbsp;</td>';
print "</tr>";
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note";
$sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql.= " WHERE p.fk_soc = ".$societe->id;
$sql.= " ORDER by p.datec";
@ -330,7 +330,7 @@ if ( $societe->fetch($socid) )
print "<tr $bc[$var]>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->idp.'">';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowContact"),"contact");
print ' '.$obj->firstname.' '. $obj->name.'</a>&nbsp;';
@ -340,16 +340,16 @@ if ( $societe->fetch($socid) )
}
print "</td>";
print "<td>$obj->poste&nbsp;</td>";
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->phone.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_FAX&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->fax.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->idp.'&socid='.$societe->id.'">'.$obj->email.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_TEL&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->phone.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_FAX&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->fax.'</a>&nbsp;</td>';
print '<td><a href="../comm/action/fiche.php?action=create&actioncode=AC_EMAIL&contactid='.$obj->rowid.'&socid='.$societe->id.'">'.$obj->email.'</a>&nbsp;</td>';
if ($user->rights->societe->contact->creer)
{
print "<td align=\"center\"><a href=\"../contact/fiche.php?action=edit&amp;id=$obj->idp\">".img_edit()."</a></td>";
print "<td align=\"center\"><a href=\"../contact/fiche.php?action=edit&amp;id=".$obj->rowid."\">".img_edit()."</a></td>";
}
print '<td align="center"><a href="../comm/action/fiche.php?action=create&actionid=5&contactid='.$obj->idp.'&socid='.$societe->id.'">';
print '<td align="center"><a href="../comm/action/fiche.php?action=create&actionid=5&contactid='.$obj->rowid.'&socid='.$societe->id.'">';
print img_object($langs->trans("Rendez-Vous"),"action");
print '</a></td>';

View File

@ -188,12 +188,12 @@ class Fournisseur extends Societe
$this->nb=array();
$sql = "SELECT count(s.idp) as nb, s.fournisseur";
$sql = "SELECT count(s.rowid) as nb, s.fournisseur";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.fournisseur = 1";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " GROUP BY s.fournisseur";
$resql=$this->db->query($sql);
if ($resql)

View File

@ -1317,7 +1317,7 @@ class CommandeFournisseur extends Commande
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE fournisseur=1 LIMIT 10";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE fournisseur=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{

View File

@ -169,9 +169,9 @@ class FactureFournisseur extends Facture
$sql.= ' total_ht, total_tva, total_ttc, fk_user_author,';
$sql.= ' fk_statut, paye, f.note, f.note_public,';
$sql.= ' '.$this->db->pdate('date_lim_reglement').'as de,';
$sql.= ' s.nom as socnom, s.idp as socid';
$sql.= ' s.nom as socnom, s.rowid as socid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
$sql.= ' WHERE f.rowid='.$rowid.' AND f.fk_soc = s.idp';
$sql.= ' WHERE f.rowid='.$rowid.' AND f.fk_soc = s.rowid';
dolibarr_syslog("FactureFourn::Fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
@ -653,7 +653,7 @@ class FactureFournisseur extends Facture
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE fournisseur=1 LIMIT 10";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE fournisseur=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{

View File

@ -115,7 +115,7 @@ $sql = "SELECT count(cf.rowid), fk_statut,";
$sql.= " cf.rowid,cf.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,";
$sql.= " ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sql.= " WHERE cf.fk_soc = s.idp ";
$sql.= " WHERE cf.fk_soc = s.rowid ";
$sql.= " GROUP BY cf.fk_statut";
$resql = $db->query($sql);
@ -158,9 +158,9 @@ else
if ($conf->fournisseur->enabled)
{
$langs->load("orders");
$sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.idp";
$sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0";
$sql.= " WHERE c.fk_soc = s.rowid AND c.fk_statut = 0";
if ($socid)
{
$sql .= " AND c.fk_soc = ".$socid;
@ -189,7 +189,7 @@ if ($conf->fournisseur->enabled)
print $commandestatic->getNomUrl(1,'',16);
print '</td>';
print '<td>';
$companystatic->id=$obj->idp;
$companystatic->id=$obj->socid;
$companystatic->nom=$obj->nom;
$companystatic->client=0;
print $companystatic->getNomUrl(1,'',16);
@ -215,9 +215,9 @@ if ($conf->fournisseur->enabled)
if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire)
{
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, f.type,";
$sql.= " s.nom, s.idp";
$sql.= " s.nom, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0";
$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
if ($socid)
{
$sql .= " AND f.fk_soc = ".$socid;
@ -247,7 +247,7 @@ if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire)
print $facturestatic->getNomUrl(1,'');
print '</td>';
print '<td>';
$companystatic->id=$obj->idp;
$companystatic->id=$obj->rowid;
$companystatic->nom=$obj->nom;
$companystatic->client=0;
print $companystatic->getNomUrl(1,'',16);
@ -284,14 +284,14 @@ print '<td valign="top" width="70%" class="notopnoleft">';
* Liste des 10 derniers saisis
*
*/
$sql = "SELECT s.idp, s.nom, s.ville,".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm";
$sql = "SELECT s.rowid as socid, s.nom, s.ville,".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm";
$sql.= " , code_fournisseur, code_compta_fournisseur";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.fk_stcomm = st.id AND s.fournisseur=1";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.idp=".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= " ORDER BY s.datec DESC LIMIT 10; ";
@ -315,8 +315,8 @@ if ($resql)
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
print "&nbsp;<a href=\"fiche.php?socid=$obj->idp\">$obj->nom</a></td>\n";
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
print "&nbsp;<a href=\"fiche.php?socid=".$obj->socid."\">".$obj->nom."</a></td>\n";
print '<td align="left">'.$obj->code_fournisseur.'&nbsp;</td>';
print '<td align="right">'.dolibarr_print_date($obj->datec,'day').'</td>';
print "</tr>\n";

View File

@ -65,16 +65,16 @@ if (! $sortfield) $sortfield="nom";
* Mode Liste
*
*/
$sql = "SELECT s.idp, s.nom, s.ville,".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm";
$sql = "SELECT s.rowid as socid, s.nom, s.ville,".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm";
$sql.= " , code_fournisseur, code_compta_fournisseur";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
if ($_GET["cat"]) $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cf";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.fk_stcomm = st.id AND s.fournisseur=1";
if ($_GET["cat"]) $sql .= " AND cf.fk_societe=s.idp AND cf.fk_categorie='".$_GET["cat"]."'";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.idp=".$socid;
if ($_GET["cat"]) $sql .= " AND cf.fk_societe = s.rowid AND cf.fk_categorie='".$_GET["cat"]."'";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
if ($socname) {
$sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'";
$sortfield = "lower(s.nom)";
@ -137,8 +137,8 @@ if ($resql)
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
print "&nbsp;<a href=\"fiche.php?socid=$obj->idp\">$obj->nom</a></td>\n";
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").'</a>';
print "&nbsp;<a href=\"fiche.php?socid=".$obj->socid."\">".$obj->nom."</a></td>\n";
print "<td>".$obj->ville."</td>\n";
print '<td align="left">'.$obj->code_fournisseur.'&nbsp;</td>';
print '<td align="left">'.$obj->code_compta_fournisseur.'&nbsp;</td>';

View File

@ -173,9 +173,9 @@ print '</table>';
* Liste des factures
*/
$allow_delete = 1 ;
$sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.idp';
$sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.idp';
$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
$sql .= ' AND pf.fk_paiementfourn = '.$paiement->id;
$resql=$db->query($sql);
if ($resql)
@ -207,7 +207,7 @@ if ($resql)
print $objp->facnumber;
print "</a></td>\n";
print '<td align="center">'.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
print '<td align="right">'.price($objp->amount).'</td>';
print "</tr>\n";
if ($objp->paye == 1)

Some files were not shown because too many files have changed in this diff Show More