Fix: Uniformisation du nom du champ id societe. On prend partout "socid".
This commit is contained in:
parent
27e6cb8ab7
commit
f9d90c3908
@ -139,7 +139,7 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
|
||||
|
||||
$com = new Commande($db);
|
||||
|
||||
$com->socidp = 4;
|
||||
$com->socid = 4;
|
||||
$com->date_commande = $dates[rand(1, sizeof($dates)-1)];
|
||||
$com->note = $_POST["note"];
|
||||
$com->source = 1;
|
||||
|
||||
@ -33,411 +33,407 @@
|
||||
|
||||
class Cotisation
|
||||
{
|
||||
var $id;
|
||||
var $db;
|
||||
var $date;
|
||||
var $amount;
|
||||
var $prenom;
|
||||
var $nom;
|
||||
var $societe;
|
||||
var $adresse;
|
||||
var $cp;
|
||||
var $ville;
|
||||
var $pays;
|
||||
var $email;
|
||||
var $public;
|
||||
var $projetid;
|
||||
var $modepaiement;
|
||||
var $modepaiementid;
|
||||
var $commentaire;
|
||||
var $statut;
|
||||
var $id;
|
||||
var $db;
|
||||
var $date;
|
||||
var $amount;
|
||||
var $prenom;
|
||||
var $nom;
|
||||
var $societe;
|
||||
var $adresse;
|
||||
var $cp;
|
||||
var $ville;
|
||||
var $pays;
|
||||
var $email;
|
||||
var $public;
|
||||
var $projetid;
|
||||
var $modepaiement;
|
||||
var $modepaiementid;
|
||||
var $commentaire;
|
||||
var $statut;
|
||||
|
||||
var $projet;
|
||||
var $errorstr;
|
||||
var $projet;
|
||||
var $errorstr;
|
||||
|
||||
/*!
|
||||
\brief Cotisation
|
||||
\param DB base de données
|
||||
\param socidp
|
||||
*/
|
||||
|
||||
function Cotisation($DB, $socidp="")
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->modepaiementid = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function print_error_list()
|
||||
{
|
||||
$num = sizeof($this->errorstr);
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
print "<li>" . $this->errorstr[$i];
|
||||
}
|
||||
}
|
||||
/**
|
||||
\brief Cotisation
|
||||
\param DB Handler base de données
|
||||
\param socid ID societe
|
||||
*/
|
||||
function Cotisation($DB, $socid="")
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->modepaiementid = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function check($minimum=0)
|
||||
{
|
||||
$err = 0;
|
||||
|
||||
if (strlen(trim($this->societe)) == 0)
|
||||
*
|
||||
*
|
||||
*/
|
||||
function print_error_list()
|
||||
{
|
||||
if ((strlen(trim($this->nom)) + strlen(trim($this->prenom))) == 0)
|
||||
{
|
||||
$error_string[$err] = "Vous devez saisir vos nom et prénom ou le nom de votre société.";
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(trim($this->adresse)) == 0)
|
||||
{
|
||||
$error_string[$err] = "L'adresse saisie est invalide";
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (strlen(trim($this->cp)) == 0)
|
||||
{
|
||||
$error_string[$err] = "Le code postal saisi est invalide";
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (strlen(trim($this->ville)) == 0)
|
||||
{
|
||||
$error_string[$err] = "La ville saisie est invalide";
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (strlen(trim($this->email)) == 0)
|
||||
{
|
||||
$error_string[$err] = "L'email saisi est invalide";
|
||||
$err++;
|
||||
}
|
||||
|
||||
$this->amount = trim($this->amount);
|
||||
|
||||
$map = range(0,9);
|
||||
for ($i = 0; $i < strlen($this->amount) ; $i++)
|
||||
{
|
||||
if (!isset($map[substr($this->amount, $i, 1)] ))
|
||||
{
|
||||
$error_string[$err] = "Le montant du don contient un/des caractère(s) invalide(s)";
|
||||
$err++;
|
||||
$amount_invalid = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $amount_invalid)
|
||||
{
|
||||
if ($this->amount == 0)
|
||||
{
|
||||
$error_string[$err] = "Le montant du don est null";
|
||||
$err++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->amount < $minimum && $minimum > 0)
|
||||
$num = sizeof($this->errorstr);
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
$error_string[$err] = "Le montant minimum du don est de $minimum";
|
||||
$err++;
|
||||
print "<li>" . $this->errorstr[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return errors
|
||||
*
|
||||
*/
|
||||
|
||||
if ($err)
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function check($minimum=0)
|
||||
{
|
||||
$this->errorstr = $error_string;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
$err = 0;
|
||||
|
||||
if (strlen(trim($this->societe)) == 0)
|
||||
{
|
||||
if ((strlen(trim($this->nom)) + strlen(trim($this->prenom))) == 0)
|
||||
{
|
||||
$error_string[$err] = "Vous devez saisir vos nom et prénom ou le nom de votre société.";
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(trim($this->adresse)) == 0)
|
||||
{
|
||||
$error_string[$err] = "L'adresse saisie est invalide";
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (strlen(trim($this->cp)) == 0)
|
||||
{
|
||||
$error_string[$err] = "Le code postal saisi est invalide";
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (strlen(trim($this->ville)) == 0)
|
||||
{
|
||||
$error_string[$err] = "La ville saisie est invalide";
|
||||
$err++;
|
||||
}
|
||||
|
||||
if (strlen(trim($this->email)) == 0)
|
||||
{
|
||||
$error_string[$err] = "L'email saisi est invalide";
|
||||
$err++;
|
||||
}
|
||||
|
||||
$this->amount = trim($this->amount);
|
||||
|
||||
$map = range(0,9);
|
||||
for ($i = 0; $i < strlen($this->amount) ; $i++)
|
||||
{
|
||||
if (!isset($map[substr($this->amount, $i, 1)] ))
|
||||
{
|
||||
$error_string[$err] = "Le montant du don contient un/des caractère(s) invalide(s)";
|
||||
$err++;
|
||||
$amount_invalid = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $amount_invalid)
|
||||
{
|
||||
if ($this->amount == 0)
|
||||
{
|
||||
$error_string[$err] = "Le montant du don est null";
|
||||
$err++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->amount < $minimum && $minimum > 0)
|
||||
{
|
||||
$error_string[$err] = "Le montant minimum du don est de $minimum";
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return errors
|
||||
*
|
||||
*/
|
||||
|
||||
if ($err)
|
||||
{
|
||||
$this->errorstr = $error_string;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
/**
|
||||
\brief fonction qui permet de créer le don
|
||||
\param userid userid de l'adhérent
|
||||
*/
|
||||
|
||||
*/
|
||||
function create($userid)
|
||||
{
|
||||
/*
|
||||
* Insertion dans la base
|
||||
*/
|
||||
|
||||
$this->date = $this->db->idate($this->date);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."don (datec, amount, fk_paiement,prenom, nom, societe,adresse, cp, ville, pays, public, fk_don_projet, note, fk_user_author, datedon, email)";
|
||||
$sql .= " VALUES (now(), $this->amount, $this->modepaiementid,'$this->prenom','$this->nom','$this->societe','$this->adresse', '$this->cp','$this->ville','$this->pays',$this->public, $this->projetid, '$this->commentaire', $userid, '$this->date','$this->email')";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return $this->db->last_insert_id(MAIN_DB_PREFIX."don");
|
||||
/*
|
||||
* Insertion dans la base
|
||||
*/
|
||||
|
||||
$this->date = $this->db->idate($this->date);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."don (datec, amount, fk_paiement,prenom, nom, societe,adresse, cp, ville, pays, public, fk_don_projet, note, fk_user_author, datedon, email)";
|
||||
$sql .= " VALUES (now(), $this->amount, $this->modepaiementid,'$this->prenom','$this->nom','$this->societe','$this->adresse', '$this->cp','$this->ville','$this->pays',$this->public, $this->projetid, '$this->commentaire', $userid, '$this->date','$this->email')";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return $this->db->last_insert_id(MAIN_DB_PREFIX."don");
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de mettre à jour le don
|
||||
\param userid userid de l'adhérent
|
||||
*/
|
||||
|
||||
function update($userid)
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de mettre à jour le don
|
||||
\param userid userid de l'adhérent
|
||||
*/
|
||||
$this->date = $this->db->idate($this->date);
|
||||
|
||||
function update($userid)
|
||||
{
|
||||
|
||||
$this->date = $this->db->idate($this->date);
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET ";
|
||||
$sql .= "amount = " . $this->amount;
|
||||
$sql .= ",fk_paiement = ".$this->modepaiementid;
|
||||
$sql .= ",prenom = '".$this->prenom ."'";
|
||||
$sql .= ",nom='".$this->nom."'";
|
||||
$sql .= ",societe='".$this->societe."'";
|
||||
$sql .= ",adresse='".$this->adresse."'";
|
||||
$sql .= ",cp='".$this->cp."'";
|
||||
$sql .= ",ville='".$this->ville."'";
|
||||
$sql .= ",pays='".$this->pays."'";
|
||||
$sql .= ",public=".$this->public;
|
||||
$sql .= ",fk_don_projet=".$this->projetid;
|
||||
$sql .= ",note='".$this->commentaire."'";
|
||||
$sql .= ",datedon='".$this->date."'";
|
||||
$sql .= ",email='".$this->email."'";
|
||||
$sql .= ",fk_statut=".$this->statut;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET ";
|
||||
$sql .= "amount = " . $this->amount;
|
||||
$sql .= ",fk_paiement = ".$this->modepaiementid;
|
||||
$sql .= ",prenom = '".$this->prenom ."'";
|
||||
$sql .= ",nom='".$this->nom."'";
|
||||
$sql .= ",societe='".$this->societe."'";
|
||||
$sql .= ",adresse='".$this->adresse."'";
|
||||
$sql .= ",cp='".$this->cp."'";
|
||||
$sql .= ",ville='".$this->ville."'";
|
||||
$sql .= ",pays='".$this->pays."'";
|
||||
$sql .= ",public=".$this->public;
|
||||
$sql .= ",fk_don_projet=".$this->projetid;
|
||||
$sql .= ",note='".$this->commentaire."'";
|
||||
$sql .= ",datedon='".$this->date."'";
|
||||
$sql .= ",email='".$this->email."'";
|
||||
$sql .= ",fk_statut=".$this->statut;
|
||||
$sql .= " WHERE rowid = $this->id";
|
||||
|
||||
$sql .= " WHERE rowid = $this->id";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de supprimer le don
|
||||
\param rowid
|
||||
*/
|
||||
|
||||
function delete($rowid)
|
||||
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de supprimer le don
|
||||
\param rowid
|
||||
*/
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;";
|
||||
|
||||
function delete($rowid)
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/*!
|
||||
\brief fonction qui permet de récupèrer le don
|
||||
\param rowid
|
||||
*/
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;";
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT d.rowid, ".$this->db->pdate("d.datedon")." as datedon, d.prenom, d.nom, d.societe, d.amount, p.libelle as projet, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."don_projet as p, ".MAIN_DB_PREFIX."c_paiement as cp";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
$sql .= " WHERE p.rowid = d.fk_don_projet AND cp.id = d.fk_paiement AND d.rowid = $rowid";
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de récupèrer le don
|
||||
\param rowid
|
||||
*/
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT d.rowid, ".$this->db->pdate("d.datedon")." as datedon, d.prenom, d.nom, d.societe, d.amount, p.libelle as projet, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."don_projet as p, ".MAIN_DB_PREFIX."c_paiement as cp";
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$sql .= " WHERE p.rowid = d.fk_don_projet AND cp.id = d.fk_paiement AND d.rowid = $rowid";
|
||||
$this->id = $obj->rowid;
|
||||
$this->date = $obj->datedon;
|
||||
$this->prenom = stripslashes($obj->prenom);
|
||||
$this->nom = stripslashes($obj->nom);
|
||||
$this->societe = stripslashes($obj->societe);
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->adresse = stripslashes($obj->adresse);
|
||||
$this->cp = stripslashes($obj->cp);
|
||||
$this->ville = stripslashes($obj->ville);
|
||||
$this->email = stripslashes($obj->email);
|
||||
$this->pays = stripslashes($obj->pays);
|
||||
$this->projet = $obj->projet;
|
||||
$this->projetid = $obj->fk_don_projet;
|
||||
$this->public = $obj->public;
|
||||
$this->modepaiementid = $obj->fk_paiement;
|
||||
$this->modepaiement = $obj->libelle;
|
||||
$this->amount = $obj->amount;
|
||||
$this->commentaire = stripslashes($obj->note);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
}
|
||||
|
||||
$obj = $this->db->fetch_object();
|
||||
/*!
|
||||
\brief fonction qui permet de valider la promesse de don
|
||||
\param rowid
|
||||
\param userid userid de l'adhérent
|
||||
*/
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->date = $obj->datedon;
|
||||
$this->prenom = stripslashes($obj->prenom);
|
||||
$this->nom = stripslashes($obj->nom);
|
||||
$this->societe = stripslashes($obj->societe);
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->adresse = stripslashes($obj->adresse);
|
||||
$this->cp = stripslashes($obj->cp);
|
||||
$this->ville = stripslashes($obj->ville);
|
||||
$this->email = stripslashes($obj->email);
|
||||
$this->pays = stripslashes($obj->pays);
|
||||
$this->projet = $obj->projet;
|
||||
$this->projetid = $obj->fk_don_projet;
|
||||
$this->public = $obj->public;
|
||||
$this->modepaiementid = $obj->fk_paiement;
|
||||
$this->modepaiement = $obj->libelle;
|
||||
$this->amount = $obj->amount;
|
||||
$this->commentaire = stripslashes($obj->note);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
function valid_promesse($rowid, $userid)
|
||||
{
|
||||
|
||||
}
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = $userid WHERE rowid = $rowid AND fk_statut = 0;";
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de valider la promesse de don
|
||||
\param rowid
|
||||
\param userid userid de l'adhérent
|
||||
*/
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function valid_promesse($rowid, $userid)
|
||||
{
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = $userid WHERE rowid = $rowid AND fk_statut = 0;";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de définir la cotisation comme payée
|
||||
\param rowid rowid de la cotisation
|
||||
\param modepaiement mode de paiement
|
||||
*/
|
||||
/*!
|
||||
\brief fonction qui permet de définir la cotisation comme payée
|
||||
\param rowid rowid de la cotisation
|
||||
\param modepaiement mode de paiement
|
||||
*/
|
||||
|
||||
function set_paye($rowid, $modepaiement='')
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
|
||||
|
||||
if ($modepaiement)
|
||||
{
|
||||
$sql .= ", fk_paiement=$modepaiement";
|
||||
}
|
||||
$sql .= " WHERE rowid = $rowid AND fk_statut = 1;";
|
||||
if ($modepaiement)
|
||||
{
|
||||
$sql .= ", fk_paiement=$modepaiement";
|
||||
}
|
||||
$sql .= " WHERE rowid = $rowid AND fk_statut = 1;";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de mettre un commentaire sur le don
|
||||
\param rowid
|
||||
\param commentaire
|
||||
*/
|
||||
/*!
|
||||
\brief fonction qui permet de mettre un commentaire sur le don
|
||||
\param rowid
|
||||
\param commentaire
|
||||
*/
|
||||
|
||||
function set_commentaire($rowid, $commentaire='')
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET note = '$commentaire'";
|
||||
function set_commentaire($rowid, $commentaire='')
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET note = '$commentaire'";
|
||||
|
||||
$sql .= " WHERE rowid = $rowid ;";
|
||||
$sql .= " WHERE rowid = $rowid ;";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief fonction qui permet de mettre le don comme encaissé
|
||||
\param rowid
|
||||
*/
|
||||
/*!
|
||||
\brief fonction qui permet de mettre le don comme encaiss
|
||||
\param rowid
|
||||
*/
|
||||
|
||||
function set_encaisse($rowid)
|
||||
{
|
||||
{
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 3 WHERE rowid = $rowid AND fk_statut = 2;";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 3 WHERE rowid = $rowid AND fk_statut = 2;";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->affected_rows() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -752,7 +752,7 @@ class BonPrelevement
|
||||
if ($fact->fetch($fac[0]) >= 0)
|
||||
{
|
||||
$soc = new Societe($this->db);
|
||||
if ($soc->fetch($fact->socidp) >= 0)
|
||||
if ($soc->fetch($fact->socid) >= 0)
|
||||
{
|
||||
if ($soc->verif_rib() == 1)
|
||||
{
|
||||
@ -763,8 +763,8 @@ class BonPrelevement
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Erreur de RIB societe $fact->socidp $soc->nom");
|
||||
$facture_errors[$fac[0]]="Erreur de RIB societe $fact->socidp $soc->nom";
|
||||
dolibarr_syslog("Erreur de RIB societe $fact->socid $soc->nom");
|
||||
$facture_errors[$fac[0]]="Erreur de RIB societe $fact->socid $soc->nom";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -47,7 +47,7 @@ $upload_dir = $conf->actions->dir_output.'/'.$_GET['id'];
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ $langs->load("orders");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
if (isset($_GET["error"])) $error=$_GET["error"];
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
|
||||
|
||||
$langs->load("companies");
|
||||
|
||||
$socidp = isset($_GET["socid"])?$_GET["socid"]:$_POST["socid"];
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:$_POST["socid"];
|
||||
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
|
||||
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
|
||||
$page = isset($_GET["page"])?$_GET["page"]:$_POST["page"];
|
||||
@ -43,7 +43,7 @@ $page = isset($_GET["page"])?$_GET["page"]:$_POST["page"];
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
@ -62,12 +62,12 @@ llxHeader();
|
||||
*
|
||||
*/
|
||||
|
||||
$sql = "SELECT s.nom as societe, s.idp as socidp, s.client,";
|
||||
$sql = "SELECT s.nom as societe, s.idp as socid, s.client,";
|
||||
$sql.= " a.id,".$db->pdate("a.datep")." as dp, a.fk_contact, a.note, a.percent as percent,";
|
||||
$sql.= " c.code as acode, c.libelle, u.code, u.rowid as userid";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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";
|
||||
if ($_GET["type"])
|
||||
{
|
||||
@ -77,11 +77,11 @@ if ($_GET["time"] == "today")
|
||||
{
|
||||
$sql .= " AND date_format(a.datep, '%d%m%Y') = ".strftime("%d%m%Y",time());
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -101,10 +101,10 @@ if ($resql)
|
||||
if ($status == 'todo') $title="ToDoActions";
|
||||
$param="&status=$status";
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($socidp);
|
||||
$societe->fetch($socid);
|
||||
|
||||
print_barre_liste($langs->trans($title."For",$societe->nom), $page, "index.php",$param,$sortfield,$sortorder,'',$num);
|
||||
}
|
||||
@ -178,7 +178,7 @@ if ($resql)
|
||||
if ($obj->client == 1) $url=DOL_URL_ROOT.'/comm/fiche.php?socid=';
|
||||
elseif ($obj->client == 2) $url=DOL_URL_ROOT.'/comm/prospect/fiche.php?id=';
|
||||
else $url=DOL_URL_ROOT.'/soc.php?socid=';
|
||||
print ' <a href="'.$url.$obj->socidp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->societe,24).'</a></td>';
|
||||
print ' <a href="'.$url.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->societe,24).'</a></td>';
|
||||
|
||||
// Contact
|
||||
print '<td>';
|
||||
|
||||
@ -38,7 +38,7 @@ $langs->load("commercial");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -149,7 +149,7 @@ class CommActionRapport
|
||||
$pdf->SetFont('Arial','',8);
|
||||
$y=$pdf->GetY()+1;
|
||||
|
||||
$sql = "SELECT s.nom as societe, s.idp as socidp, s.client, a.id,".$this->db->pdate("a.datea")." as da, a.datea, c.libelle, u.code, a.fk_contact, a.note, a.percent as percent";
|
||||
$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.code, 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";
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ if ($_GET["projetid"])
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$result=$soc->fetch($_GET["socidp"]);
|
||||
$result=$soc->fetch($_GET["socid"]);
|
||||
if ($result < 0)
|
||||
{
|
||||
dolibarr_print_error($db,$soc->error);
|
||||
@ -97,7 +97,7 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
}
|
||||
|
||||
print "<form name='addprop' action=\"propal.php?socidp=".$soc->id."\" method=\"post\">";
|
||||
print "<form name='addprop' action=\"propal.php?socid=".$soc->id."\" method=\"post\">";
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
@ -112,7 +112,7 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
// Societe
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$soc->getNomUrl(1);
|
||||
print '<input type="hidden" name="socidp" value="'.$soc->id.'">';
|
||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -218,7 +218,7 @@ if ($conf->expedition->enabled)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans('DeliveryAddress').'</td>';
|
||||
print '<td colspan="3">';
|
||||
$numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socidp'],'adresse_livraison_id',1);
|
||||
$numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socid'],'adresse_livraison_id',1);
|
||||
if ($numaddress==0)
|
||||
{
|
||||
print ' <a href=../comm/adresse_livraison.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddAddress").'</a>';
|
||||
@ -245,7 +245,7 @@ if ($conf->expedition->enabled)
|
||||
$numprojet=$html->select_projects($soc->id,$projetid,'projetidp');
|
||||
if ($numprojet==0)
|
||||
{
|
||||
print ' <a href="../projet/fiche.php?socidp='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||
print ' <a href="../projet/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -108,7 +108,7 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
|
||||
}
|
||||
elseif ($origin == propal)
|
||||
{
|
||||
Header("Location: ../comm/propal.php?action=editdelivery_adress&socidp=".$socid."&propalid=".$originid);
|
||||
Header("Location: ../comm/propal.php?action=editdelivery_adress&socid=".$socid."&propalid=".$originid);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
|
||||
@ -35,7 +35,7 @@ if (!$user->rights->societe->lire) accessforbidden();
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$page=$_GET["page"];
|
||||
@ -60,7 +60,7 @@ $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 ($socidp) $sql .= " AND s.idp = $socidp";
|
||||
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;
|
||||
|
||||
|
||||
@ -84,13 +84,13 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
|
||||
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 .= " WHERE s.fk_stcomm = st.id";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = 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";
|
||||
|
||||
@ -46,21 +46,21 @@ if ($conf->fichinter->enabled) $langs->load("interventions");
|
||||
$user->getrights("commercial");
|
||||
if (!$user->rights->societe->lire) accessforbidden();
|
||||
|
||||
$socidp = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
if ($socidp == '') accessforbidden();
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
if ($socid == '') accessforbidden();
|
||||
|
||||
// Protection quand utilisateur externe
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Protection restriction commercial
|
||||
if (!$user->rights->commercial->client->voir && $socidp && !$user->societe_id > 0)
|
||||
if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0)
|
||||
{
|
||||
$sql = "SELECT sc.fk_soc, s.client";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE sc.fk_soc = ".$socidp." AND sc.fk_user = ".$user->id." AND s.client = 1";
|
||||
$sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_user = ".$user->id." AND s.client = 1";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
@ -106,7 +106,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='".$socidp."'";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE idp='".$socid."'";
|
||||
$result = $db->query($sql);
|
||||
if (! $result) dolibarr_print_error($result);
|
||||
}
|
||||
@ -116,12 +116,12 @@ if ($action == 'stcomm')
|
||||
if ($stcommid <> 'null' && $stcommid <> $oldstcomm)
|
||||
{
|
||||
$sql = "INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) ";
|
||||
$sql .= " VALUES ('$dateaction',$socidp,$stcommid,'" . $user->login . "')";
|
||||
$sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $user->login . "')";
|
||||
$result = @$db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=".$socidp;
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=".$socid;
|
||||
$result = $db->query($sql);
|
||||
}
|
||||
else
|
||||
@ -132,7 +132,7 @@ if ($action == 'stcomm')
|
||||
|
||||
if ($actioncommid)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea, fk_action, fk_soc, fk_user_author) VALUES ('$dateaction',$actioncommid,$socidp,'" . $user->id . "')";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea, fk_action, fk_soc, fk_user_author) VALUES ('$dateaction',$actioncommid,$socid,'" . $user->id . "')";
|
||||
$result = @$db->query($sql);
|
||||
|
||||
if (!$result)
|
||||
@ -149,17 +149,17 @@ if ($action == 'stcomm')
|
||||
if ($mode == 'search') {
|
||||
if ($mode-search == 'soc') {
|
||||
$sql = "SELECT s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
|
||||
if ( $db->query($sql) ) {
|
||||
if ( $db->num_rows() == 1) {
|
||||
$obj = $db->fetch_object();
|
||||
$socidp = $obj->idp;
|
||||
$socid = $obj->idp;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
@ -175,12 +175,12 @@ llxHeader('',$langs->trans('CustomerCard'));
|
||||
* Mode fiche
|
||||
*
|
||||
*********************************************************************************/
|
||||
if ($socidp > 0)
|
||||
if ($socid > 0)
|
||||
{
|
||||
// On recupere les donnees societes par l'objet
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->id=$socidp;
|
||||
$objsoc->fetch($socidp,$to);
|
||||
$objsoc->id=$socid;
|
||||
$objsoc->fetch($socid,$to);
|
||||
|
||||
$dac = strftime("%Y-%m-%d %H:%M", time());
|
||||
if ($errmesg)
|
||||
@ -406,7 +406,7 @@ if ($socidp > 0)
|
||||
if ($num > 0)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socidp='.$objsoc->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td></tr></table></td>';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$objsoc->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td></tr></table></td>';
|
||||
print '</tr>';
|
||||
$var=!$var;
|
||||
}
|
||||
@ -459,7 +459,7 @@ if ($socidp > 0)
|
||||
if ($num >0 )
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/liste.php?socidp='.$objsoc->id.'">'.$langs->trans("AllOrders").' ('.$num.')</a></td></tr></table></td>';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/liste.php?socid='.$objsoc->id.'">'.$langs->trans("AllOrders").' ('.$num.')</a></td></tr></table></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
$i = 0;
|
||||
@ -552,7 +552,7 @@ if ($socidp > 0)
|
||||
if ($num >0 )
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/fichinter/index.php?socidp='.$objsoc->id.'">'.$langs->trans("AllInterventions").' ('.$num.')</td></tr></table></td>';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/fichinter/index.php?socid='.$objsoc->id.'">'.$langs->trans("AllInterventions").' ('.$num.')</td></tr></table></td>';
|
||||
print '</tr>';
|
||||
$var=!$var;
|
||||
}
|
||||
@ -628,13 +628,13 @@ if ($socidp > 0)
|
||||
if ($conf->propal->enabled && $user->rights->propale->creer)
|
||||
{
|
||||
$langs->load("propal");
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddProp").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$objsoc->id.'&action=create">'.$langs->trans("AddProp").'</a>';
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled && $user->rights->commande->creer)
|
||||
{
|
||||
$langs->load("orders");
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddOrder").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socid='.$objsoc->id.'&action=create">'.$langs->trans("AddOrder").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->contrat->creer)
|
||||
@ -646,7 +646,7 @@ if ($socidp > 0)
|
||||
if ($conf->fichinter->enabled && $user->rights->ficheinter->creer)
|
||||
{
|
||||
$langs->load("fichinter");
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/fiche.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddIntervention").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/fiche.php?socid='.$objsoc->id.'&action=create">'.$langs->trans("AddIntervention").'</a>';
|
||||
}
|
||||
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$objsoc->id.'">'.$langs->trans("AddAction").'</a>';
|
||||
|
||||
@ -39,12 +39,12 @@ $langs->load("commercial");
|
||||
$langs->load("orders");
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp='';
|
||||
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
|
||||
$socid='';
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$max=5;
|
||||
@ -60,12 +60,12 @@ if ($conf->propal->enabled) $propalstatic=new Propal($db);
|
||||
|
||||
if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark')
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$_GET["socidp"]." AND fk_user=".$user->id;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$_GET["socid"]." AND fk_user=".$user->id;
|
||||
if (! $db->query($sql) )
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$_GET["socidp"].", now(),".$user->id.");";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$_GET["socid"].", now(),".$user->id.");";
|
||||
if (! $db->query($sql) )
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
@ -131,15 +131,15 @@ if ($conf->contrat->enabled)
|
||||
if ($conf->propal->enabled && $user->rights->propale->lire)
|
||||
{
|
||||
$sql = "SELECT p.rowid, p.ref, p.price, s.idp, s.nom";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
@ -183,14 +183,14 @@ if ($conf->commande->enabled)
|
||||
{
|
||||
$langs->load("orders");
|
||||
$sql = "SELECT c.rowid, c.ref, c.total_ttc, s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp)
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND c.fk_soc = $socidp";
|
||||
$sql .= " AND c.fk_soc = $socid";
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -233,9 +233,9 @@ if ($conf->commande->enabled)
|
||||
$sql = "SELECT s.idp, 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;
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
$sql .= " ORDER BY lower(s.nom) ASC";
|
||||
|
||||
@ -279,14 +279,14 @@ print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
|
||||
*/
|
||||
|
||||
$sql = "SELECT a.id, a.label, ".$db->pdate("a.datep")." as dp, c.code, c.libelle, a.fk_user_author, s.nom as sname, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp)
|
||||
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 = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
$sql .= " ORDER BY a.datep DESC, a.id DESC";
|
||||
|
||||
@ -350,15 +350,15 @@ else
|
||||
*/
|
||||
|
||||
$sql = "SELECT a.id, a.percent, ".$db->pdate("a.datea")." as da, c.code, c.libelle, a.fk_user_author, s.nom as sname, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = ".$socidp;
|
||||
$sql .= " AND s.idp = ".$socid;
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -419,15 +419,15 @@ else
|
||||
if ($user->rights->societe->lire)
|
||||
{
|
||||
$sql = "SELECT s.idp,s.nom,".$db->pdate("datec")." as datec";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.client = 1";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -476,15 +476,15 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -531,12 +531,12 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp) $sql .= " AND s.idp = $socidp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $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.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql .= " ORDER BY p.rowid DESC";
|
||||
|
||||
$result=$db->query($sql);
|
||||
@ -588,15 +588,15 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql .= " ORDER BY p.rowid DESC";
|
||||
$sql .= $db->plimit($NBMAX, 0);
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ if (!$user->rights->mailing->lire) accessforbidden();
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$page=$_GET["page"];
|
||||
|
||||
@ -58,12 +58,12 @@ $year=isset($_GET["year"])?$_GET["year"]:"";
|
||||
$month=isset($_GET["month"])?$_GET["month"]:"";
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp='';
|
||||
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
|
||||
$socid='';
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Nombre de ligne pour choix de produit/service prédéfinis
|
||||
@ -165,7 +165,7 @@ if ($_POST['action'] == 'set_ref_client' && $user->rights->propale->creer)
|
||||
if ($_POST['action'] == 'add' && $user->rights->propale->creer)
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$propal->socidp=$_POST['socidp'];
|
||||
$propal->socid=$_POST['socid'];
|
||||
$propal->fetch_client();
|
||||
|
||||
$db->begin();
|
||||
@ -183,7 +183,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
|
||||
$propal->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
$propal->remise_percent = $_POST['remise_percent'];
|
||||
$propal->remise_absolue = $_POST['remise_absolue'];
|
||||
$propal->socidp = $_POST['socidp'];
|
||||
$propal->socid = $_POST['socid'];
|
||||
$propal->contactid = $_POST['contactidp'];
|
||||
$propal->projetidp = $_POST['projetidp'];
|
||||
$propal->modelpdf = $_POST['model'];
|
||||
@ -304,7 +304,7 @@ if ($_POST['action'] == 'send')
|
||||
$file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf';
|
||||
if (is_readable($file))
|
||||
{
|
||||
$soc = new Societe($db, $propal->socidp);
|
||||
$soc = new Societe($db, $propal->socid);
|
||||
if ($_POST['sendto'])
|
||||
{
|
||||
// Le destinataire a été fourni via le champ libre
|
||||
@ -370,7 +370,7 @@ if ($_POST['action'] == 'send')
|
||||
$actioncomm->date = time(); // L'action est faite maintenant
|
||||
$actioncomm->percent = 100;
|
||||
$actioncomm->contact = new Contact($db,$sendtoid);
|
||||
$actioncomm->societe = new Societe($db,$propal->socidp);
|
||||
$actioncomm->societe = new Societe($db,$propal->socid);
|
||||
$actioncomm->user = $user; // User qui a fait l'action
|
||||
$actioncomm->propalrowid = $propal->id;
|
||||
$ret=$actioncomm->add($user); // User qui saisi l'action
|
||||
@ -455,8 +455,8 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$ret=$propal->fetch($_POST['propalid']);
|
||||
$soc = new Societe($db, $propal->socidp);
|
||||
$soc->fetch($propal->socidp);
|
||||
$soc = new Societe($db, $propal->socid);
|
||||
$soc->fetch($propal->socid);
|
||||
|
||||
// Ecrase $pu par celui du produit
|
||||
// Ecrase $desc par celui du produit
|
||||
@ -689,7 +689,7 @@ if ($_GET['propalid'] > 0)
|
||||
}
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socidp);
|
||||
$societe->fetch($propal->socid);
|
||||
|
||||
$head = propal_prepare_head($propal);
|
||||
dolibarr_fiche_head($head, 'comm', $langs->trans('Proposal'));
|
||||
@ -869,17 +869,17 @@ if ($conf->expedition->enabled)
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socidp='.$propal->socidp.'&propalid='.$propal->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$propal->socid.'&propalid='.$propal->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
|
||||
if ($_GET['action'] == 'editdelivery_adress')
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'adresse_livraison_id','propal',$propal->id);
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','propal',$propal->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'none','propal',$propal->id);
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socid'],'none','propal',$propal->id);
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -936,7 +936,7 @@ if ($conf->expedition->enabled)
|
||||
print '</td></tr></table>';
|
||||
print '<td colspan="2">';
|
||||
print $langs->trans("NoProject").'</td><td>';
|
||||
print '<a href=../projet/fiche.php?socidp='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>';
|
||||
print '<a href=../projet/fiche.php?socid='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
@ -948,11 +948,11 @@ if ($conf->expedition->enabled)
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$form->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socidp, $propal->projetidp, 'projetidp');
|
||||
$form->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'projetidp');
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socidp, $propal->projetidp, 'none');
|
||||
$form->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -1071,7 +1071,7 @@ if ($conf->expedition->enabled)
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socidp.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socid.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ' - '.nl2br($objp->description);
|
||||
@ -1596,7 +1596,7 @@ if ($conf->expedition->enabled)
|
||||
$sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ;
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
|
||||
$sql .= ' WHERE a.propalrowid = '.$propal->id ;
|
||||
if ($socidp) $sql .= ' AND a.fk_soc = '.$socidp;
|
||||
if ($socid) $sql .= ' AND a.fk_soc = '.$socid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -1698,13 +1698,13 @@ else
|
||||
$pagenext = $page + 1;
|
||||
|
||||
$sql = 'SELECT s.nom, s.idp, s.client, 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 && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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';
|
||||
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -1721,7 +1721,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 ($socidp) $sql .= ' AND s.idp = '.$socidp;
|
||||
if ($socid) $sql .= ' AND s.idp = '.$socid;
|
||||
if ($_GET['viewstatut'] <> '')
|
||||
{
|
||||
$sql .= ' AND p.fk_statut in ('.$_GET['viewstatut'].')';
|
||||
@ -1750,16 +1750,16 @@ else
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
print_barre_liste($langs->trans('ListOfProposals'), $page,'propal.php','&socidp='.$socidp,$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste($langs->trans('ListOfProposals'), $page,'propal.php','&socid='.$socid,$sortfield,$sortorder,'',$num);
|
||||
$i = 0;
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),$_SERVER["PHP_SELF"],'s.nom','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'p.datep','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('DateEndPropalShort'),$_SERVER["PHP_SELF"],'dfv','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Price'),$_SERVER["PHP_SELF"],'p.price','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','','&socid='.$socid.'&viewstatut='.$viewstatut,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),$_SERVER["PHP_SELF"],'s.nom','','&socid='.$socid.'&viewstatut='.$viewstatut,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'p.datep','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('DateEndPropalShort'),$_SERVER["PHP_SELF"],'dfv','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Price'),$_SERVER["PHP_SELF"],'p.price','','&socid='.$socid.'&viewstatut='.$viewstatut, 'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','','&socid='.$socid.'&viewstatut='.$viewstatut,'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
|
||||
@ -39,7 +39,7 @@ include_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ if ($_GET["propalid"])
|
||||
$propal->fetch($_GET["propalid"]);
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socidp);
|
||||
$societe->fetch($propal->socid);
|
||||
|
||||
$head[0][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
|
||||
$head[0][1] = "Proposition commerciale : $propal->ref";
|
||||
|
||||
@ -50,7 +50,7 @@ $langs->load('compta');
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -71,8 +71,8 @@ if ($_GET["propalid"] > 0)
|
||||
|
||||
if ( $propal->fetch($_GET["propalid"], $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $propal->socidp);
|
||||
$soc->fetch($propal->socidp);
|
||||
$soc = new Societe($db, $propal->socid);
|
||||
$soc->fetch($propal->socid);
|
||||
|
||||
$head = propal_prepare_head($propal);
|
||||
dolibarr_fiche_head($head, 'preview', $langs->trans('Proposal'));
|
||||
@ -85,7 +85,7 @@ if ($_GET["propalid"] > 0)
|
||||
$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 ($socidp) $sql .= ' AND s.idp = '.$socidp;
|
||||
if ($socid) $sql .= ' AND s.idp = '.$socid;
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ function select_type_contact($propal, $defValue, $htmlname = 'type', $source)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -220,8 +220,8 @@ if ($id > 0)
|
||||
$propal = New Propal($db);
|
||||
if ( $propal->fetch($_GET['propalid'], $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $propal->socidp);
|
||||
$soc->fetch($propal->socidp);
|
||||
$soc = new Societe($db, $propal->socid);
|
||||
$soc->fetch($propal->socid);
|
||||
|
||||
|
||||
$head = propal_prepare_head($propal);
|
||||
|
||||
@ -109,7 +109,7 @@ if ($propalid > 0)
|
||||
$upload_dir = $conf->propal->dir_output.'/'.$propref;
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socidp);
|
||||
$societe->fetch($propal->socid);
|
||||
|
||||
$head = propal_prepare_head($propal);
|
||||
dolibarr_fiche_head($head, 'document', $langs->trans('Proposal'));
|
||||
|
||||
@ -56,7 +56,7 @@ $propal = new Propal($db);
|
||||
$propal->fetch($_GET['propalid']);
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socidp);
|
||||
$societe->fetch($propal->socid);
|
||||
|
||||
$head = propal_prepare_head($propal);
|
||||
dolibarr_fiche_head($head, 'info', $langs->trans('Proposal'));
|
||||
|
||||
@ -46,7 +46,7 @@ if (!$user->rights->propale->lire)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
unset($_GET['action']);
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@ -109,7 +109,7 @@ if ($_GET['propalid'])
|
||||
if ( $propal->fetch($_GET['propalid']) )
|
||||
{
|
||||
$societe = new Societe($db);
|
||||
if ( $societe->fetch($propal->socidp) )
|
||||
if ( $societe->fetch($propal->socid) )
|
||||
{
|
||||
$head = propal_prepare_head($propal);
|
||||
dolibarr_fiche_head($head, 'note', $langs->trans('Proposal'));
|
||||
|
||||
@ -177,7 +177,7 @@ if ($socid > 0)
|
||||
{
|
||||
$tableaushown=1;
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socidp='.$societe->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td></tr></table></td>';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$societe->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td></tr></table></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
@ -222,12 +222,12 @@ if ($socid > 0)
|
||||
|
||||
if ($conf->propal->enabled && defined("MAIN_MODULE_PROPALE") && MAIN_MODULE_PROPALE && $user->rights->propale->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socidp='.$societe->id.'&action=create">'.$langs->trans("AddProp").'</a>';
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProp").'</a>';
|
||||
}
|
||||
|
||||
if ($conf->projet->enabled && $user->rights->projet->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$socid.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/projet/fiche.php?socid='.$socid.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ $user->getrights('propale');
|
||||
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -73,11 +73,11 @@ if ($conf->propal->enabled)
|
||||
*/
|
||||
|
||||
$sql = "SELECT count(*) as cc, st.libelle, st.id";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql .= " GROUP BY st.id";
|
||||
$sql .= " ORDER BY st.id";
|
||||
|
||||
@ -114,11 +114,11 @@ if ($resql)
|
||||
if ($conf->propal->enabled && $user->rights->propale->lire)
|
||||
{
|
||||
$sql = "SELECT p.rowid, p.ref, p.price, s.nom";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
@ -165,11 +165,11 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql .= " ORDER BY a.datea DESC";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
@ -218,12 +218,12 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp) $sql .= " AND s.idp = $socidp";
|
||||
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 .= " ORDER BY p.rowid DESC";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
|
||||
@ -267,11 +267,11 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql .= " ORDER BY s.tms ASC";
|
||||
$sql .= $db->plimit(15, 0);
|
||||
|
||||
|
||||
@ -38,11 +38,11 @@ $user->getrights('commande');
|
||||
$user->getrights('projet');
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp=0;
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$socname=isset($_GET["socname"])?$_GET["socname"]:$_POST["socname"];
|
||||
@ -77,12 +77,12 @@ if ($_GET["action"] == 'cstc')
|
||||
|
||||
$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 .= ", d.nom as departement";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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";
|
||||
|
||||
// Avec MySQL 5.0 la procédure de requêtes jointes (JOIN) a changé pour suivre les standards plus correctement.
|
||||
// référence: http://dev.mysql.com/doc/refman/5.0/fr/join.html
|
||||
if (!$user->rights->commercial->client->voir && !$socidp)
|
||||
if (!$user->rights->commercial->client->voir && !$socid)
|
||||
{
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc)";
|
||||
}
|
||||
@ -93,7 +93,7 @@ else
|
||||
|
||||
$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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
if (isset($stcomm))
|
||||
{
|
||||
|
||||
@ -60,7 +60,7 @@ if ($conf->projet->enabled)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
@ -78,8 +78,8 @@ if ($_GET["id"] > 0) {
|
||||
|
||||
if ( $commande->fetch($_GET["id"], $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $commande->socidp);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc = new Societe($db, $commande->socid);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
|
||||
$head = commande_prepare_head($commande);
|
||||
@ -94,7 +94,7 @@ if ($_GET["id"] > 0) {
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande as c';
|
||||
$sql.= ' WHERE c.fk_soc = s.idp';
|
||||
$sql.= ' AND c.rowid = '.$commande->id;
|
||||
if ($socidp) $sql .= ' AND s.idp = '.$socidp;
|
||||
if ($socid) $sql .= ' AND s.idp = '.$socid;
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ class Commande extends CommonObject
|
||||
|
||||
var $id ;
|
||||
|
||||
var $socidp; // Id client
|
||||
var $socid; // Id client
|
||||
var $client; // Objet societe client (à charger par fetch_client)
|
||||
|
||||
var $ref;
|
||||
@ -77,12 +77,12 @@ class Commande extends CommonObject
|
||||
* \brief Constructeur
|
||||
* \param DB Handler d'accès base
|
||||
*/
|
||||
function Commande($DB, $socidp="", $commandeid=0)
|
||||
function Commande($DB, $socid="", $commandeid=0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('orders');
|
||||
$this->db = $DB;
|
||||
$this->socidp = $socidp;
|
||||
$this->socid = $socid;
|
||||
$this->id = $commandeid;
|
||||
|
||||
$this->sources[0] = $langs->trans('OrderSource0');
|
||||
@ -126,7 +126,7 @@ class Commande extends CommonObject
|
||||
$this->lines[$i] = $CommLigne;
|
||||
}
|
||||
|
||||
$this->socidp = $propal->socidp;
|
||||
$this->socid = $propal->socid;
|
||||
$this->projetid = $propal->projetidp;
|
||||
$this->cond_reglement_id = $propal->cond_reglement_id;
|
||||
$this->mode_reglement_id = $propal->mode_reglement_id;
|
||||
@ -137,7 +137,7 @@ class Commande extends CommonObject
|
||||
|
||||
/* Définit la société comme un client */
|
||||
$soc = new Societe($this->db);
|
||||
$soc->id = $this->socidp;
|
||||
$soc->id = $this->socid;
|
||||
$soc->set_as_client();
|
||||
$this->propale_id = $propal->id;
|
||||
|
||||
@ -174,7 +174,7 @@ class Commande extends CommonObject
|
||||
// Recuperation de la nouvelle reference
|
||||
$objMod = new $modName($this->db);
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->socidp);
|
||||
$soc->fetch($this->socid);
|
||||
|
||||
// Classe la société rattachée comme client
|
||||
$result=$soc->set_as_client();
|
||||
@ -373,7 +373,7 @@ class Commande extends CommonObject
|
||||
if (! $this->projetid) $this->projetid = 0;
|
||||
|
||||
$soc = new Societe($this->db);
|
||||
$result=$soc->fetch($this->socidp);
|
||||
$result=$soc->fetch($this->socid);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error="Failed to fetch company";
|
||||
@ -387,7 +387,7 @@ class Commande extends CommonObject
|
||||
$sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_public, ref_client,';
|
||||
$sql.= ' model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison,';
|
||||
$sql.= ' remise_absolue, remise_percent)';
|
||||
$sql.= ' VALUES ('.$this->socidp.', now(), '.$user->id.', '.$this->projetid.',';
|
||||
$sql.= ' VALUES ('.$this->socid.', now(), '.$user->id.', '.$this->projetid.',';
|
||||
$sql.= ' '.$this->db->idate($this->date_commande).',';
|
||||
$sql.= ' '.$this->source.', ';
|
||||
$sql.= " '".addslashes($this->note)."', ";
|
||||
@ -440,7 +440,7 @@ class Commande extends CommonObject
|
||||
$this->db->query($sql);
|
||||
|
||||
// On récupère les différents contact interne et externe
|
||||
$prop = New Propal($this->db, $this->socidp, $this->propale_id);
|
||||
$prop = New Propal($this->db, $this->socid, $this->propale_id);
|
||||
|
||||
// On récupère le commercial suivi propale
|
||||
$this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
|
||||
@ -795,7 +795,7 @@ class Commande extends CommonObject
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_client = $obj->ref_client;
|
||||
$this->socidp = $obj->fk_soc;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
$this->total_ht = $obj->total_ht;
|
||||
@ -2012,7 +2012,7 @@ class Commande extends CommonObject
|
||||
$this->ref = 'SPECIMEN';
|
||||
$this->specimen=1;
|
||||
$socid = rand(1, $num_socs);
|
||||
$this->socidp = $socids[$socid];
|
||||
$this->socid = $socids[$socid];
|
||||
$this->date = time();
|
||||
$this->date_lim_reglement=$this->date+3600*24*30;
|
||||
$this->cond_reglement_code = 'RECEP';
|
||||
|
||||
@ -106,7 +106,7 @@ function select_type_contact($commande, $defValue, $htmlname = 'type', $source)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -220,8 +220,8 @@ if ($id > 0)
|
||||
$commande = New Commande($db);
|
||||
if ( $commande->fetch($_GET['id'], $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $commande->socidp);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc = new Societe($db, $commande->socid);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
|
||||
$head = commande_prepare_head($commande);
|
||||
|
||||
@ -54,11 +54,11 @@ if (!$user->rights->commande->lire) accessforbidden();
|
||||
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp=0;
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Récupération de l'id de projet
|
||||
@ -88,7 +88,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
||||
$datelivraison = @mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']);
|
||||
|
||||
$commande = new Commande($db);
|
||||
$commande->socidp=$_POST['socidp'];
|
||||
$commande->socid=$_POST['socid'];
|
||||
$commande->fetch_client();
|
||||
|
||||
$db->begin();
|
||||
@ -149,7 +149,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
|
||||
{
|
||||
$db->rollback();
|
||||
$_GET["action"]='create';
|
||||
$_GET['socidp']=$_POST['socidp'];
|
||||
$_GET['socid']=$_POST['socid'];
|
||||
if (! $mesg) $mesg='<div class="error">'.$commande->error.'</div>';
|
||||
}
|
||||
|
||||
@ -248,8 +248,8 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$ret=$commande->fetch($_POST['id']);
|
||||
$soc = new Societe($db, $commande->socidp);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc = new Societe($db, $commande->socid);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
if ($ret < 0)
|
||||
{
|
||||
@ -375,7 +375,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc->fetch($commande->socid);
|
||||
$result = $commande->valid($user);
|
||||
}
|
||||
|
||||
@ -524,7 +524,7 @@ if ($_POST['action'] == 'send')
|
||||
$file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf';
|
||||
if (is_readable($file))
|
||||
{
|
||||
$soc = new Societe($db, $commande->socidp);
|
||||
$soc = new Societe($db, $commande->socid);
|
||||
if ($_POST['sendto'])
|
||||
{
|
||||
// Le destinataire a été fourni via le champ libre
|
||||
@ -590,7 +590,7 @@ if ($_POST['action'] == 'send')
|
||||
$actioncomm->date = time(); // L'action est faite maintenant
|
||||
$actioncomm->percent = 100;
|
||||
$actioncomm->contact = new Contact($db,$sendtoid);
|
||||
$actioncomm->societe = new Societe($db,$commande->socidp);
|
||||
$actioncomm->societe = new Societe($db,$commande->socid);
|
||||
$actioncomm->user = $user; // User qui a fait l'action
|
||||
$actioncomm->orderrowid = $commande->id;
|
||||
$ret=$actioncomm->add($user); // User qui saisi l'action
|
||||
@ -657,7 +657,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
||||
{
|
||||
$sql = 'SELECT s.nom, s.prefix_comm, s.idp, s.mode_reglement, s.cond_reglement ';
|
||||
$sql .= 'FROM '.MAIN_DB_PREFIX.'societe as s ';
|
||||
$sql .= 'WHERE s.idp = '.$_GET['socidp'];
|
||||
$sql .= 'WHERE s.idp = '.$_GET['socid'];
|
||||
}
|
||||
$resql = $db->query($sql);
|
||||
if ( $resql )
|
||||
@ -674,7 +674,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
||||
|
||||
print '<form name="crea_commande" action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="socidp" value="'.$soc->id.'">' ."\n";
|
||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
|
||||
print '<input type="hidden" name="remise_percent" value="'.$soc->remise_client.'">';
|
||||
print '<input name="facnumber" type="hidden" value="provisoire">';
|
||||
|
||||
@ -734,7 +734,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
||||
|
||||
// Adresse de livraison
|
||||
print '<tr><td nowrap="nowrap">'.$langs->trans('DeliveryAddress').'</td><td>';
|
||||
$numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socidp'],'adresse_livraison_id',1);
|
||||
$numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socid'],'adresse_livraison_id',1);
|
||||
|
||||
if ($numaddress==0)
|
||||
{
|
||||
@ -798,7 +798,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
||||
$numprojet=$html->select_projects($soc->id,$projetid,'projetid');
|
||||
if ($numprojet==0)
|
||||
{
|
||||
print ' <a href=../projet/fiche.php?socidp='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';
|
||||
print ' <a href=../projet/fiche.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -955,7 +955,7 @@ else
|
||||
if ( $commande->fetch($_GET['id']) > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
@ -1124,7 +1124,7 @@ else
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socidp.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
|
||||
@ -1187,11 +1187,11 @@ else
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'projetid');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'none');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -1283,7 +1283,7 @@ else
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$commande->socidp.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$commande->socid.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ' - '.nl2br($objp->description);
|
||||
@ -1758,7 +1758,7 @@ else
|
||||
$sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ;
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a';
|
||||
$sql .= ' WHERE a.fk_commande = '.$commande->id ;
|
||||
if ($socidp) $sql .= ' AND a.fk_soc = '.$socidp;
|
||||
if ($socid) $sql .= ' AND a.fk_soc = '.$socid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -1828,7 +1828,7 @@ else
|
||||
print_titre($langs->trans('SendOrderByMail'));
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$liste[0]=" ";
|
||||
foreach ($soc->contact_email_array() as $key=>$value)
|
||||
|
||||
@ -35,12 +35,12 @@ if (!$user->rights->commande->lire) accessforbidden();
|
||||
$langs->load("orders");
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp='';
|
||||
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
|
||||
$socid='';
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$commandestatic=new Commande($db);
|
||||
@ -73,12 +73,12 @@ print "</form></table><br>\n";
|
||||
* Commandes brouillons
|
||||
*/
|
||||
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp) $sql .= " AND c.fk_soc = ".$socidp;
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
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 ( $db->query($sql) )
|
||||
{
|
||||
@ -107,12 +107,12 @@ if ( $db->query($sql) )
|
||||
* Commandes à traiter
|
||||
*/
|
||||
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp) $sql .= " AND c.fk_soc = ".$socidp;
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
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 .= " ORDER BY c.rowid DESC";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
@ -147,12 +147,12 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp) $sql .= " AND c.fk_soc = ".$socidp;
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
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 .= " ORDER BY c.rowid DESC";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
@ -188,12 +188,12 @@ $max=5;
|
||||
|
||||
$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.idp,";
|
||||
$sql.= " ".$db->pdate("date_cloture")." as datec";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp) $sql .= " AND c.fk_soc = ".$socidp;
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
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.= " ORDER BY c.tms DESC";
|
||||
$sql.= $db->plimit($max, 0);
|
||||
|
||||
|
||||
@ -49,8 +49,8 @@ llxHeader();
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET["id"]);
|
||||
$commande->info($_GET["id"]);
|
||||
$soc = new Societe($db, $commande->socidp);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc = new Societe($db, $commande->socid);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$head = commande_prepare_head($commande);
|
||||
dolibarr_fiche_head($head, 'info', $langs->trans("CustomerOrder"));
|
||||
|
||||
@ -45,11 +45,11 @@ $snom=isset($_GET['snom'])?$_GET['snom']:$_POST['snom'];
|
||||
$sall=isset($_GET['sall'])?$_GET['sall']:$_POST['sall'];
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp = $_GET['socidp'];
|
||||
$socid = $_GET['socid'];
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -71,11 +71,11 @@ $offset = $limit * $_GET['page'] ;
|
||||
|
||||
$sql = 'SELECT s.nom, s.idp, 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 && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -87,9 +87,9 @@ if ($sall)
|
||||
{
|
||||
$sql .= " AND (c.ref like '%".addslashes($sall)."%' OR c.note like '%".addslashes($sall)."%')";
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= ' AND s.idp = '.$socidp;
|
||||
$sql .= ' AND s.idp = '.$socid;
|
||||
}
|
||||
if ($_GET['month'] > 0)
|
||||
{
|
||||
@ -132,10 +132,10 @@ $resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socidp);
|
||||
$soc->fetch($socid);
|
||||
$title = $langs->trans('ListOfOrders') . ' - '.$soc->nom;
|
||||
}
|
||||
else
|
||||
@ -145,15 +145,15 @@ if ($resql)
|
||||
if ($_GET['status'] == 3)
|
||||
$title.=' - '.$langs->trans('StatusOrderToBill');
|
||||
$num = $db->num_rows($resql);
|
||||
print_barre_liste($title, $_GET['page'], 'liste.php','&socidp='.$socidp,$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste($title, $_GET['page'], 'liste.php','&socid='.$socid,$sortfield,$sortorder,'',$num);
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans('Ref'),'liste.php','c.ref','','&socidp='.$socidp,'width="25%"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),'liste.php','s.nom','','&socidp='.$socidp,'width="30%"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('RefCustomerOrder'),'liste.php','c.ref_client','','&socidp='.$socidp,'width="15%"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),'liste.php','c.date_commande','','&socidp='.$socidp, 'width="20%" align="right" colspan="2"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Status'),'liste.php','c.fk_statut','','&socidp='.$socidp,'width="10%" align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Ref'),'liste.php','c.ref','','&socid='.$socid,'width="25%"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),'liste.php','s.nom','','&socid='.$socid,'width="30%"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('RefCustomerOrder'),'liste.php','c.ref_client','','&socid='.$socid,'width="15%"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),'liste.php','c.date_commande','','&socid='.$socid, 'width="20%" align="right" colspan="2"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Status'),'liste.php','c.fk_statut','','&socid='.$socid,'width="10%" align="center"',$sortfield);
|
||||
print '</tr>';
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="get" action="liste.php">';
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/order.lib.php');
|
||||
|
||||
$socidp=isset($_GET["socidp"])?$_GET["socidp"]:isset($_POST["socidp"])?$_POST["socidp"]:"";
|
||||
$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
|
||||
|
||||
$user->getrights('commande');
|
||||
if (!$user->rights->commande->lire)
|
||||
@ -44,7 +44,7 @@ $langs->load("orders");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
unset($_GET["action"]);
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -100,8 +100,8 @@ $html = new Form($db);
|
||||
|
||||
if ($_GET["id"])
|
||||
{
|
||||
$soc = new Societe($db, $commande->socidp);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc = new Societe($db, $commande->socid);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$head = commande_prepare_head($commande);
|
||||
|
||||
|
||||
@ -39,10 +39,10 @@ class CommandeStats extends Stats
|
||||
{
|
||||
var $db ;
|
||||
|
||||
function CommandeStats($DB, $socidp)
|
||||
function CommandeStats($DB, $socid)
|
||||
{
|
||||
$this->db = $DB;
|
||||
$this->socidp = $socidp;
|
||||
$this->socid = $socid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,12 +56,12 @@ class CommandeStats extends Stats
|
||||
|
||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socidp) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->socidp)
|
||||
if (!$user->rights->commercial->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->socid)
|
||||
{
|
||||
$sql .= " AND c.fk_soc = ".$this->socidp;
|
||||
$sql .= " AND c.fk_soc = ".$this->socid;
|
||||
}
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= " ORDER BY dm DESC";
|
||||
@ -80,12 +80,12 @@ class CommandeStats extends Stats
|
||||
|
||||
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, count(*), sum(c.total_ht)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " WHERE c.fk_statut > 0";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socidp) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->socidp)
|
||||
if (!$user->rights->commercial->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->socid)
|
||||
{
|
||||
$sql .= " AND c.fk_soc = ".$this->socidp;
|
||||
$sql .= " AND c.fk_soc = ".$this->socid;
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
@ -103,12 +103,12 @@ class CommandeStats extends Stats
|
||||
|
||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.total_ht)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socidp) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->socidp)
|
||||
if (!$user->rights->commercial->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->socid)
|
||||
{
|
||||
$sql .= " AND c.fk_soc = ".$this->socidp;
|
||||
$sql .= " AND c.fk_soc = ".$this->socid;
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
@ -126,12 +126,12 @@ class CommandeStats extends Stats
|
||||
|
||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.total_ht)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
|
||||
if (!$user->rights->commercial->client->voir && !$this->socidp) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->socidp)
|
||||
if (!$user->rights->commercial->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($this->socid)
|
||||
{
|
||||
$sql .= " AND c.fk_soc = ".$this->socidp;
|
||||
$sql .= " AND c.fk_soc = ".$this->socid;
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ if (!$user->rights->commande->lire) accessforbidden();
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ llxHeader();
|
||||
|
||||
print_fiche_titre($langs->trans("OrdersStatistics"), $mesg);
|
||||
|
||||
$stats = new CommandeStats($db, $socidp);
|
||||
$stats = new CommandeStats($db, $socid);
|
||||
|
||||
$year = strftime("%Y", time());
|
||||
$data = $stats->getNbByMonthWithPrevYear($year);
|
||||
|
||||
@ -36,7 +36,7 @@ require_once(DOL_DOCUMENT_ROOT."/dolgraph.class.php");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
@ -57,7 +57,7 @@ $HEIGHT=200;
|
||||
|
||||
print_fiche_titre($langs->trans("OrdersStatistics"), $mesg);
|
||||
|
||||
$stats = new CommandeStats($db, $socidp);
|
||||
$stats = new CommandeStats($db, $socid);
|
||||
$data = $stats->getNbByMonth($year);
|
||||
|
||||
create_exdir($conf->commande->dir_temp);
|
||||
|
||||
@ -339,7 +339,7 @@ class CommonObject
|
||||
function fetch_client()
|
||||
{
|
||||
$client = new Societe($this->db);
|
||||
$client->fetch($this->socidp);
|
||||
$client->fetch($this->socid);
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
class CompanyBankAccount
|
||||
{
|
||||
var $rowid;
|
||||
var $socidp;
|
||||
var $socid;
|
||||
|
||||
var $bank;
|
||||
var $courant;
|
||||
@ -41,7 +41,7 @@ class CompanyBankAccount
|
||||
global $config;
|
||||
|
||||
$this->db = $DB;
|
||||
$this->socidp = $socid;
|
||||
$this->socid = $socid;
|
||||
|
||||
$this->clos = 0;
|
||||
$this->solde = 0;
|
||||
@ -56,7 +56,7 @@ class CompanyBankAccount
|
||||
*/
|
||||
function create()
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socidp, now());";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, now());";
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if ($this->db->affected_rows())
|
||||
@ -79,7 +79,7 @@ class CompanyBankAccount
|
||||
{
|
||||
|
||||
$sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib ";
|
||||
$sql .= " WHERE fk_soc = ".$this->socidp;
|
||||
$sql .= " WHERE fk_soc = ".$this->socid;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
@ -116,7 +116,7 @@ class CompanyBankAccount
|
||||
$sql .= ",proprio = '".addslashes($this->proprio)."'";
|
||||
$sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'";
|
||||
|
||||
$sql .= " WHERE fk_soc = ".$this->socidp;
|
||||
$sql .= " WHERE fk_soc = ".$this->socid;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
@ -139,7 +139,7 @@ class CompanyBankAccount
|
||||
{
|
||||
|
||||
$sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
$sql .= " WHERE fk_soc = ".$this->socidp;
|
||||
$sql .= " WHERE fk_soc = ".$this->socid;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ else
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ $langs->load("tax");
|
||||
* Action ajout en bookmark
|
||||
*/
|
||||
if ($action == 'add_bookmark') {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socid, now(),".$user->id.");";
|
||||
if (! $db->query($sql) ) {
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ llxHeader();
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
if ($action == 'attribute_prefix')
|
||||
@ -131,11 +131,11 @@ if ($mode == 'search') {
|
||||
|
||||
$sql = "SELECT s.idp, 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 && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
if (strlen($stcomm))
|
||||
{
|
||||
@ -169,9 +169,9 @@ if (strlen($begin))
|
||||
$sql .= " AND s.nom like '".addslashes($begin)."'";
|
||||
}
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
|
||||
|
||||
@ -46,7 +46,7 @@ if (! $user->rights->commande->lire) accessforbidden();
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ if ($_GET["id"] > 0)
|
||||
if ( $commande->fetch($_GET["id"]) > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
@ -200,7 +200,7 @@ if ($_GET["id"] > 0)
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socidp.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
|
||||
@ -262,11 +262,11 @@ if ($_GET["id"] > 0)
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'projetid');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'none');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -348,7 +348,7 @@ if ($_GET["id"] > 0)
|
||||
print '<td>';
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$commande->socidp.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$commande->socid.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ' - '.nl2br($objp->description);
|
||||
@ -528,7 +528,7 @@ if ($_GET["id"] > 0)
|
||||
|
||||
if ($commande->statut > 0 && $user->rights->facture->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&commandeid='.$commande->id.'&socidp='.$commande->socidp.'">'.$langs->trans("CreateBill").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&commandeid='.$commande->id.'&socid='.$commande->socid.'">'.$langs->trans("CreateBill").'</a>';
|
||||
}
|
||||
|
||||
if ($commande->statut > 0 && $user->rights->commande->creer)
|
||||
|
||||
@ -42,11 +42,11 @@ $limit = $conf->liste_limit;
|
||||
$offset = $limit * $_GET["page"] ;
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp = $_GET["socidp"];
|
||||
$socid = $_GET["socid"];
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$langs->load('companies');
|
||||
@ -58,14 +58,14 @@ llxHeader();
|
||||
$sql = "SELECT s.nom, s.idp,";
|
||||
$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 && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp)
|
||||
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 = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
if ($_GET["month"] > 0)
|
||||
{
|
||||
@ -93,10 +93,10 @@ $resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socidp);
|
||||
$soc->fetch($socid);
|
||||
$title = $langs->trans("ListOfOrders") . " - ".$soc->nom;
|
||||
}
|
||||
else
|
||||
@ -106,7 +106,7 @@ if ($resql)
|
||||
// Si page des commandes à facturer
|
||||
$link=DOL_URL_ROOT."/compta/commande/fiche.php";
|
||||
$title.=" - ".$langs->trans("StatusOrderToBill");
|
||||
$param="&socidp=".$socidp."&year=".$_GET["year"]."&month=".$_GET["month"];
|
||||
$param="&socid=".$socid."&year=".$_GET["year"]."&month=".$_GET["month"];
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
print_barre_liste($title, $_GET["page"], "liste.php",$param,$sortfield,$sortorder,'',$num);
|
||||
|
||||
@ -55,7 +55,7 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
$_POST["reyear"]);
|
||||
|
||||
$deplacement->km = $_POST["km"];
|
||||
$deplacement->socidp = $_POST["socidp"];
|
||||
$deplacement->socid = $_POST["socid"];
|
||||
$deplacement->userid = $user->id; //$_POST["km"];
|
||||
$id = $deplacement->create($user);
|
||||
|
||||
|
||||
@ -53,25 +53,25 @@ $pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp = $_GET["socidp"];
|
||||
$socid = $_GET["socid"];
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$sql = "SELECT s.nom, s.idp,"; // 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 && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1 ,$offset);
|
||||
@ -81,16 +81,16 @@ if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print_barre_liste($langs->trans("ListOfTrips"), $page, "index.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste($langs->trans("ListOfTrips"), $page, "index.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print_liste_field_titre($langs->trans("Ref"),"index.php","d.rowid","","&socidp=$socidp",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),"index.php","d.dated","","&socidp=$socidp",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","&socidp=$socidp",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Person"),"index.php","u.name","","&socidp=$socidp",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Distance"),"index.php","d.km","","&socidp=$socidp",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Ref"),"index.php","d.rowid","","&socid=$socid",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),"index.php","d.dated","","&socid=$socid",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","&socid=$socid",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Person"),"index.php","u.name","","&socid=$socid",'',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Distance"),"index.php","d.km","","&socid=$socid",'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
$var=true;
|
||||
|
||||
@ -28,7 +28,7 @@ llxHeader('','Compta - Export');
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -55,13 +55,13 @@ $langs->load('main');
|
||||
|
||||
$sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']);
|
||||
$mesg=isset($_GET['mesg'])?urldecode($_GET['mesg']):'';
|
||||
$socidp=isset($_GET['socidp'])?$_GET['socidp']:$_POST['socidp'];
|
||||
$socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid'];
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Récupération de l'id de projet
|
||||
@ -152,7 +152,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($_GET['facid']);
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($fac->socidp);
|
||||
$soc->fetch($fac->socid);
|
||||
$result = $fac->set_valid($fac->id, $user, $soc);
|
||||
if ($result >= 0)
|
||||
{
|
||||
@ -270,7 +270,7 @@ if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes'
|
||||
if ($_POST['action'] == 'add' && $user->rights->facture->creer)
|
||||
{
|
||||
$facture = new Facture($db);
|
||||
$facture->socidp=$_POST['socid'];
|
||||
$facture->socid=$_POST['socid'];
|
||||
$facture->fetch_client();
|
||||
|
||||
$db->begin();
|
||||
@ -313,7 +313,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
|
||||
// Si facture récurrente
|
||||
$datefacture = mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||
|
||||
$facture->socidp = $_POST['socid'];
|
||||
$facture->socid = $_POST['socid'];
|
||||
$facture->type = $_POST['type'];
|
||||
$facture->number = $_POST['facnumber'];
|
||||
$facture->date = $datefacture;
|
||||
@ -331,7 +331,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
|
||||
// Si facture standard
|
||||
$datefacture = mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||
|
||||
$facture->socidp = $_POST['socid'];
|
||||
$facture->socid = $_POST['socid'];
|
||||
$facture->type = $_POST['type'];
|
||||
$facture->number = $_POST['facnumber'];
|
||||
$facture->date = $datefacture;
|
||||
@ -534,7 +534,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
|
||||
$fac = new Facture($db);
|
||||
$ret=$fac->fetch($_POST['facid']);
|
||||
$soc = new Societe($db);
|
||||
$ret=$soc->fetch($fac->socidp);
|
||||
$ret=$soc->fetch($fac->socid);
|
||||
|
||||
$date_start='';
|
||||
$date_end='';
|
||||
@ -752,7 +752,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc = new Societe($db, $fac->socid);
|
||||
|
||||
if ($_POST['sendto']) {
|
||||
// Le destinataire a été fourni via le champ libre
|
||||
@ -836,7 +836,7 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c
|
||||
$actioncomm->date = time();
|
||||
$actioncomm->percent = 100;
|
||||
$actioncomm->contact = new Contact($db,$sendtoid);
|
||||
$actioncomm->societe = new Societe($db,$fac->socidp);
|
||||
$actioncomm->societe = new Societe($db,$fac->socid);
|
||||
$actioncomm->user = $user; // User qui a fait l'action
|
||||
$actioncomm->facid = $fac->id;
|
||||
|
||||
@ -966,7 +966,7 @@ if ($_GET['action'] == 'create')
|
||||
{
|
||||
$propal = New Propal($db);
|
||||
$propal->fetch($_GET['propalid']);
|
||||
$societe_id = $propal->socidp;
|
||||
$societe_id = $propal->socid;
|
||||
$projetid=$propal->projetidp;
|
||||
$ref_client=$propal->ref_client;
|
||||
|
||||
@ -980,7 +980,7 @@ if ($_GET['action'] == 'create')
|
||||
{
|
||||
$commande = New Commande($db);
|
||||
$commande->fetch($_GET['commandeid']);
|
||||
$societe_id = $commande->socidp;
|
||||
$societe_id = $commande->socid;
|
||||
$projetid=$commande-> projet_id;
|
||||
$ref_client=$commande->ref_client;
|
||||
|
||||
@ -1005,7 +1005,7 @@ if ($_GET['action'] == 'create')
|
||||
}
|
||||
else
|
||||
{
|
||||
$societe_id=$socidp;
|
||||
$societe_id=$socid;
|
||||
|
||||
$soc->fetch($societe_id);
|
||||
$cond_reglement_id = $soc->cond_reglement;
|
||||
@ -1043,7 +1043,7 @@ if ($_GET['action'] == 'create')
|
||||
// Societe
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">';
|
||||
print $soc->getNomUrl(1);
|
||||
print '<input type="hidden" name="socidp" value="'.$soc->id.'">';
|
||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -1419,7 +1419,7 @@ if ($_GET['action'] == 'create')
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socidp.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socid.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
}
|
||||
@ -1482,8 +1482,8 @@ else
|
||||
$fac = New Facture($db);
|
||||
if ( $fac->fetch($_GET['facid'], $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc->fetch($fac->socidp);
|
||||
$soc = new Societe($db, $fac->socid);
|
||||
$soc->fetch($fac->socid);
|
||||
$absolute_discount=$soc->getCurrentDiscount();
|
||||
|
||||
$totalpaye = $fac->getSommePaiement();
|
||||
@ -1533,7 +1533,7 @@ else
|
||||
require_once(DOL_DOCUMENT_ROOT ."/notify.class.php");
|
||||
$notify=new Notify($db);
|
||||
$text.='<br>';
|
||||
$text.=$notify->confirmMessage(2,$fac->socidp);
|
||||
$text.=$notify->confirmMessage(2,$fac->socid);
|
||||
}
|
||||
|
||||
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ValidateBill'),$text,'confirm_valid');
|
||||
@ -1839,11 +1839,11 @@ else
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socidp,$fac->projetid,'projetid');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->projetid,'projetid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socidp,$fac->projetid,'none');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->projetid,'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -1926,7 +1926,7 @@ else
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$fac->socidp.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$fac->socid.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ' - '.nl2br($objp->description);
|
||||
@ -2516,7 +2516,7 @@ else
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a, '.MAIN_DB_PREFIX.'user as u ';
|
||||
$sql .= ' WHERE a.fk_user_author = u.rowid ';
|
||||
$sql .= ' AND a.fk_action in (9,10) ';
|
||||
$sql .= ' AND a.fk_soc = '.$fac->socidp ;
|
||||
$sql .= ' AND a.fk_soc = '.$fac->socid ;
|
||||
$sql .= ' AND a.fk_facture = '.$fac->id;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -2709,7 +2709,7 @@ else
|
||||
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 ($socidp) $sql .= ' AND s.idp = '.$socidp;
|
||||
if ($socid) $sql .= ' AND s.idp = '.$socid;
|
||||
if ($month > 0) $sql .= ' AND date_format(f.datef, \'%m\') = '.$month;
|
||||
if ($_GET['filtre'])
|
||||
{
|
||||
@ -2764,24 +2764,24 @@ else
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socidp);
|
||||
$soc->fetch($socid);
|
||||
}
|
||||
|
||||
print_barre_liste($langs->trans('BillsCustomers').' '.($socidp?' '.$soc->nom:''),$page,'facture.php','&socidp='.$socidp,$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->nom:''),$page,'facture.php','&socid='.$socid,$sortfield,$sortorder,'',$num);
|
||||
|
||||
$i = 0;
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'f.facnumber','','&socidp='.$socidp,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'f.datef','','&socidp='.$socidp,'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),$_SERVER['PHP_SELF'],'s.nom','','&socidp='.$socidp,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('AmountHT'),$_SERVER['PHP_SELF'],'f.total','','&socidp='.$socidp,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('AmountTTC'),$_SERVER['PHP_SELF'],'f.total_ttc','','&socidp='.$socidp,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Received'),$_SERVER['PHP_SELF'],'am','','&socidp='.$socidp,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut,paye,am','','&socidp='.$socidp,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'f.facnumber','','&socid='.$socid,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'f.datef','','&socid='.$socid,'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),$_SERVER['PHP_SELF'],'s.nom','','&socid='.$socid,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('AmountHT'),$_SERVER['PHP_SELF'],'f.total','','&socid='.$socid,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('AmountTTC'),$_SERVER['PHP_SELF'],'f.total_ttc','','&socid='.$socid,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Received'),$_SERVER['PHP_SELF'],'am','','&socid='.$socid,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut,paye,am','','&socid='.$socid,'align="right"',$sortfield);
|
||||
print '</tr>';
|
||||
|
||||
// Lignes des champs de filtre
|
||||
|
||||
@ -45,7 +45,7 @@ $langs->load("bills");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -64,8 +64,8 @@ if ($_GET["facid"] > 0)
|
||||
$fac = New Facture($db);
|
||||
if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc->fetch($fac->socidp);
|
||||
$soc = new Societe($db, $fac->socid);
|
||||
$soc->fetch($fac->socid);
|
||||
$author = new User($db);
|
||||
if ($fac->user_author)
|
||||
{
|
||||
|
||||
@ -107,7 +107,7 @@ function select_type_contact($facture, $defValue, $htmlname = 'type', $source)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -111,7 +111,7 @@ if ($facid > 0)
|
||||
$upload_dir = $conf->facture->dir_output.'/'.$facref;
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($facture->socidp);
|
||||
$societe->fetch($facture->socid);
|
||||
|
||||
$head = facture_prepare_head($facture);
|
||||
dolibarr_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'));
|
||||
|
||||
@ -43,7 +43,7 @@ class FactureRec extends Facture
|
||||
|
||||
var $id ;
|
||||
|
||||
var $socidp; // Id client
|
||||
var $socid; // Id client
|
||||
var $client; // Objet societe client (à charger par fetch_client)
|
||||
|
||||
var $number;
|
||||
@ -97,7 +97,7 @@ class FactureRec extends Facture
|
||||
$this->brouillon = 1;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (titre, fk_soc, datec, amount, remise, remise_percent, note, fk_user_author,fk_projet, fk_cond_reglement) ";
|
||||
$sql.= " VALUES ('$this->titre', '$facsrc->socidp', now(), '$facsrc->amount', '$facsrc->remise', '$facsrc->remise_percent', '".addslashes($this->note)."','$user->id',";
|
||||
$sql.= " VALUES ('$this->titre', '$facsrc->socid', now(), '$facsrc->amount', '$facsrc->remise', '$facsrc->remise_percent', '".addslashes($this->note)."','$user->id',";
|
||||
$sql.= " ".($facsrc->projetid?"'".$facsrc->projetid."'":"null").", ";
|
||||
$sql.= " '".$facsrc->cond_reglement_id."')";
|
||||
if ( $this->db->query($sql) )
|
||||
@ -175,7 +175,7 @@ class FactureRec extends Facture
|
||||
$this->total_ttc = $obj->total_ttc;
|
||||
$this->paye = $obj->paye;
|
||||
$this->remise_percent = $obj->remise_percent;
|
||||
$this->socidp = $obj->fk_soc;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->date_lim_reglement = $obj->dlr;
|
||||
$this->cond_reglement_id = $obj->crid;
|
||||
|
||||
@ -58,7 +58,7 @@ $sortfield="f.datef";
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -283,8 +283,8 @@ else
|
||||
|
||||
if ( $fac->fetch($facid, $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc->fetch($fac->socidp);
|
||||
$soc = new Societe($db, $fac->socid);
|
||||
$soc->fetch($fac->socid);
|
||||
$author = new User($db);
|
||||
$author->id = $fac->user_author;
|
||||
$author->fetch();
|
||||
@ -402,8 +402,8 @@ else
|
||||
$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";
|
||||
|
||||
if ($socidp)
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
if ($socid)
|
||||
$sql .= " AND s.idp = $socid";
|
||||
|
||||
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
|
||||
// $sql .= $db->plimit($limit + 1,$offset);
|
||||
@ -413,13 +413,13 @@ else
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
print_barre_liste($langs->trans("RepeatableInvoice"),$page,"fiche-rec.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste($langs->trans("RepeatableInvoice"),$page,"fiche-rec.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socidp=$socidp");
|
||||
print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socid=$socid");
|
||||
print '</td><td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print '<td> </td>';
|
||||
print "</td>\n";
|
||||
|
||||
@ -43,13 +43,13 @@ $langs->load("bills");
|
||||
|
||||
|
||||
|
||||
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -76,15 +76,15 @@ if ($user->rights->facture->lire)
|
||||
$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 && ! $socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && ! $socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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.= " AND f.paye = 0 AND f.fk_statut = 1";
|
||||
if (! $user->rights->commercial->client->voir && ! $socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp) $sql .= " AND s.idp = $socidp";
|
||||
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["filtre"])
|
||||
{
|
||||
@ -135,26 +135,26 @@ if ($user->rights->facture->lire)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socidp);
|
||||
$soc->fetch($socid);
|
||||
}
|
||||
|
||||
$titre=($socidp?$langs->trans("BillsCustomersUnpayedForCompany",$soc->nom):$langs->trans("BillsCustomersUnpayed"));
|
||||
print_barre_liste($titre,$page,"impayees.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
|
||||
$titre=($socid?$langs->trans("BillsCustomersUnpayedForCompany",$soc->nom):$langs->trans("BillsCustomersUnpayed"));
|
||||
print_barre_liste($titre,$page,"impayees.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
$i = 0;
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&socidp=$socidp","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&socidp=$socidp",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&socidp=$socidp",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&socidp=$socidp","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","","&socidp=$socidp",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","","&socidp=$socidp",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","","&socidp=$socidp",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","","&socidp=$socidp",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=$socid","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","","&socid=$socid",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","","&socid=$socid",'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&socid=$socid","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","","&socid=$socid",'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","","&socid=$socid",'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
// Lignes des champs de filtre
|
||||
|
||||
@ -44,8 +44,8 @@ $fac = new Facture($db);
|
||||
$fac->fetch($_GET["facid"]);
|
||||
$fac->info($_GET["facid"]);
|
||||
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc->fetch($fac->socidp);
|
||||
$soc = new Societe($db, $fac->socid);
|
||||
$soc->fetch($fac->socid);
|
||||
|
||||
$head = facture_prepare_head($fac);
|
||||
dolibarr_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"));
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php');
|
||||
|
||||
$socidp=isset($_GET["socidp"])?$_GET["socidp"]:isset($_POST["socidp"])?$_POST["socidp"]:"";
|
||||
$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
|
||||
|
||||
$user->getrights('facture');
|
||||
if (!$user->rights->facture->lire)
|
||||
@ -43,7 +43,7 @@ $langs->load("bills");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
unset($_GET["action"]);
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -99,8 +99,8 @@ $html = new Form($db);
|
||||
|
||||
if ($_GET["facid"])
|
||||
{
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc->fetch($fac->socidp);
|
||||
$soc = new Societe($db, $fac->socid);
|
||||
$soc->fetch($fac->socid);
|
||||
|
||||
$head = facture_prepare_head($fac);
|
||||
$hselected = 2;
|
||||
|
||||
@ -44,7 +44,7 @@ $langs->load("withdrawals");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -102,8 +102,8 @@ if ($_GET["facid"] > 0)
|
||||
{
|
||||
if ($mesg) print $mesg.'<br>';
|
||||
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc->fetch($fac->socidp);
|
||||
$soc = new Societe($db, $fac->socid);
|
||||
$soc->fetch($fac->socid);
|
||||
|
||||
$author = new User($db);
|
||||
if ($fac->user_author)
|
||||
|
||||
@ -40,10 +40,10 @@ class FactureStats extends Stats
|
||||
{
|
||||
var $db ;
|
||||
|
||||
function FactureStats($DB, $socidp=0)
|
||||
function FactureStats($DB, $socid=0)
|
||||
{
|
||||
$this->db = $DB;
|
||||
$this->socidp = $socidp;
|
||||
$this->socid = $socid;
|
||||
}
|
||||
|
||||
|
||||
@ -55,9 +55,9 @@ class FactureStats extends Stats
|
||||
{
|
||||
$sql = "SELECT date_format(datef,'%m') as dm, count(*) FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql .= " WHERE date_format(datef,'%Y') = $year AND fk_statut > 0";
|
||||
if ($this->socidp)
|
||||
if ($this->socid)
|
||||
{
|
||||
$sql .= " AND fk_soc = ".$this->socidp;
|
||||
$sql .= " AND fk_soc = ".$this->socid;
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
@ -84,9 +84,9 @@ class FactureStats extends Stats
|
||||
{
|
||||
$sql = "SELECT date_format(datef,'%m') as dm, sum(total) FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql .= " WHERE date_format(datef,'%Y') = $year AND fk_statut > 0";
|
||||
if ($this->socidp)
|
||||
if ($this->socid)
|
||||
{
|
||||
$sql .= " AND fk_soc = ".$this->socidp;
|
||||
$sql .= " AND fk_soc = ".$this->socid;
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
@ -100,9 +100,9 @@ class FactureStats extends Stats
|
||||
{
|
||||
$sql = "SELECT date_format(datef,'%m') as dm, avg(total) FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql .= " WHERE date_format(datef,'%Y') = $year AND fk_statut > 0";
|
||||
if ($this->socidp)
|
||||
if ($this->socid)
|
||||
{
|
||||
$sql .= " AND fk_soc = ".$this->socidp;
|
||||
$sql .= " AND fk_soc = ".$this->socid;
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
|
||||
@ -37,14 +37,14 @@ $HEIGHT=200;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_fiche_titre($langs->trans("BillsStatistics"), $mesg);
|
||||
|
||||
$stats = new FactureStats($db, $socidp);
|
||||
$stats = new FactureStats($db, $socid);
|
||||
$year = strftime("%Y", time());
|
||||
$data = $stats->getNbByMonthWithPrevYear($year);
|
||||
|
||||
@ -70,9 +70,9 @@ if (! $mesg)
|
||||
}
|
||||
|
||||
$sql = "SELECT count(*) as nb, date_format(datef,'%Y') as dm, sum(total) as total FROM ".MAIN_DB_PREFIX."facture WHERE fk_statut > 0 ";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND fk_soc = $socidp";
|
||||
$sql .= " AND fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC ";
|
||||
$resql=$db->query($sql);
|
||||
|
||||
@ -37,7 +37,7 @@ $GRAPHHEIGHT=200;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ $mesg.= ' <a href="month.php?year='.($year + 1).'">'.img_next().'</a>';
|
||||
|
||||
print_fiche_titre($langs->trans("BillsStatistics"), $mesg);
|
||||
|
||||
$stats = new FactureStats($db, $socidp);
|
||||
$stats = new FactureStats($db, $socid);
|
||||
$data = $stats->getNbByMonth($year);
|
||||
|
||||
create_exdir($conf->facture->dir_temp);
|
||||
|
||||
@ -255,7 +255,7 @@ if ($socid > 0)
|
||||
{
|
||||
$tableaushown=1;
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture.php?socidp='.$societe->id.'">'.$langs->trans("AllBills").' ('.$num.')</a></td></tr></table></td>';
|
||||
print '<td colspan="4"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$societe->id.'">'.$langs->trans("AllBills").' ('.$num.')</a></td></tr></table></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ if ($socid > 0)
|
||||
{
|
||||
$tableaushown=1;
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/projet/index.php?socidp='.$societe->id.'">'.$langs->trans("AllProjects").' ('.$num.')</td></tr></table></td>';
|
||||
print '<td colspan="2"><table width="100%" class="noborder"><tr><td>'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/projet/index.php?socid='.$societe->id.'">'.$langs->trans("AllProjects").' ('.$num.')</td></tr></table></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
while ($i < $num && $i < $MAXLIST)
|
||||
@ -346,7 +346,7 @@ if ($socid > 0)
|
||||
// Si société cliente ou prospect, on affiche bouton "Créer facture client"
|
||||
if ($societe->client != 0 && $conf->facture->enabled && $user->rights->facture->creer) {
|
||||
$langs->load("bills");
|
||||
print "<a class=\"tabAction\" href=\"".DOL_URL_ROOT."/compta/facture.php?action=create&socidp=$societe->id\">".$langs->trans("AddBill")."</a>";
|
||||
print "<a class=\"tabAction\" href=\"".DOL_URL_ROOT."/compta/facture.php?action=create&socid=$societe->id\">".$langs->trans("AddBill")."</a>";
|
||||
}
|
||||
|
||||
if ($conf->deplacement->enabled) {
|
||||
|
||||
@ -47,11 +47,11 @@ $langs->load("bills");
|
||||
if ($conf->commande->enabled) $langs->load("orders");
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp='';
|
||||
$socid='';
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -61,12 +61,12 @@ if ($user->societe_id > 0)
|
||||
|
||||
if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark')
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socidp." AND fk_user=".$user->id;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socid." AND fk_user=".$user->id;
|
||||
if (! $db->query($sql) )
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socid, now(),".$user->id.");";
|
||||
if (! $db->query($sql) )
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
@ -119,15 +119,15 @@ if ($conf->facture->enabled)
|
||||
if ($conf->facture->enabled && $user->rights->facture->lire)
|
||||
{
|
||||
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -275,16 +275,16 @@ if ($conf->facture->enabled && $conf->commande->enabled && $user->rights->comman
|
||||
$sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc,";
|
||||
$sql.= " s.nom, s.idp,";
|
||||
$sql.= " p.rowid, p.ref, p.facture, p.fk_statut, p.total_ht, p.total_ttc";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp)
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " AND p.fk_soc = $socidp";
|
||||
$sql.= " AND p.fk_soc = $socid";
|
||||
}
|
||||
$sql.= " AND p.fk_statut = 3 AND p.facture=0";
|
||||
$sql.= " GROUP BY p.rowid";
|
||||
@ -356,13 +356,13 @@ if ($conf->facture->enabled && $user->rights->facture->lire)
|
||||
$sql = "SELECT f.rowid, f.facnumber, f.fk_statut, f.total, f.total_ttc, ".$db->pdate("f.date_lim_reglement")." as datelimite,";
|
||||
$sql.= " sum(pf.amount) as am,";
|
||||
$sql.= " s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp) $sql .= " AND f.fk_soc = ".$socidp;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = 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.= " ORDER BY f.datef ASC, f.facnumber ASC";
|
||||
|
||||
@ -436,13 +436,13 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user ";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.idp = ff.fk_soc";
|
||||
$sql.= " AND ff.paye=0 AND ff.fk_statut = 1";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
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";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
|
||||
@ -185,7 +185,7 @@ if ($_POST['action'] == 'add_paiement')
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -269,7 +269,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'add_paiement')
|
||||
$sql .= ', sum(pf.amount) as am';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
|
||||
$sql .= ' WHERE f.fk_soc = '.$facture->socidp;
|
||||
$sql .= ' WHERE f.fk_soc = '.$facture->socid;
|
||||
$sql .= ' AND f.paye = 0';
|
||||
$sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validée, Statut=2 => annulée
|
||||
$sql .= ' GROUP BY f.facnumber';
|
||||
@ -376,9 +376,9 @@ if (! $_GET['action'] && ! $_POST['action'])
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c';
|
||||
$sql .= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id';
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= ' AND f.fk_soc = '.$socidp;
|
||||
$sql .= ' AND f.fk_soc = '.$socid;
|
||||
}
|
||||
|
||||
$sql .= ' ORDER BY '.$sortfield.' '.$sortorder;
|
||||
|
||||
@ -37,11 +37,11 @@ $langs->load("bills");
|
||||
if (! $user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
|
||||
$socidp=0;
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -63,15 +63,15 @@ $offset = $limit * $page ;
|
||||
$sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount, p.statut";
|
||||
$sql .=", c.libelle as paiement_type, p.num_paiement";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
|
||||
}
|
||||
$sql .= " WHERE p.fk_paiement = c.id";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " AND f.fk_soc = ".$socidp;
|
||||
$sql.= " AND f.fk_soc = ".$socid;
|
||||
}
|
||||
$sql .= " AND p.statut = 0";
|
||||
$sql .= " ORDER BY $sortfield $sortorder";
|
||||
|
||||
@ -37,11 +37,11 @@ $user->getrights("facture");
|
||||
if (! $user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
|
||||
$socidp=0;
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -68,15 +68,15 @@ $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."paiement as p";
|
||||
$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 ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
|
||||
}
|
||||
$sql.= " WHERE p.fk_paiement = c.id";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " AND f.fk_soc = ".$socidp;
|
||||
$sql.= " AND f.fk_soc = ".$socid;
|
||||
}
|
||||
if ($_GET["search_montant"])
|
||||
{
|
||||
|
||||
@ -37,11 +37,11 @@ if (! $user->rights->facture->lire)
|
||||
|
||||
$dir = $conf->compta->dir_output;
|
||||
|
||||
$socidp=0;
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
$dir = DOL_DATA_ROOT.'/private/'.$user->id.'/compta';
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ if ($_POST["action"] == 'add_paiement')
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -223,7 +223,7 @@ if ($_GET["action"] == 'create')
|
||||
// $sql .= ", sum(pf.amount) as am";
|
||||
// $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
// $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_facture = f.rowid";
|
||||
// $sql .= " WHERE f.fk_soc = ".$facture->socidp;
|
||||
// $sql .= " WHERE f.fk_soc = ".$facture->socid;
|
||||
// $sql .= " AND f.paye = 0";
|
||||
// $sql .= " AND f.fk_statut = 1"; // Statut=0 => non validée, Statut=2 => annulée
|
||||
// $sql .= " GROUP BY f.facnumber";
|
||||
|
||||
@ -40,7 +40,7 @@ $langs->load("bills");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
llxHeader("","Accueil Compta");
|
||||
|
||||
@ -41,7 +41,7 @@ $langs->load("bills");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
llxHeader("",$langs->trans("AccountancySetup"));
|
||||
|
||||
@ -45,7 +45,7 @@ llxHeader('','Pr
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -169,9 +169,9 @@ $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
$sql .= " WHERE s.idp = f.fk_soc";
|
||||
$sql .= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
|
||||
if ( $db->query($sql) )
|
||||
|
||||
@ -37,7 +37,7 @@ $langs->load("widthdrawals");
|
||||
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
@ -66,12 +66,12 @@ if (! $sortfield) $sortfield="f.facnumber";
|
||||
$sql= "SELECT f.facnumber, f.rowid, s.nom, s.idp";
|
||||
$sql.= " , ".$db->pdate("pfd.date_demande")." as date_demande";
|
||||
$sql.= " , pfd.fk_user_demande";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = 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";
|
||||
@ -79,9 +79,9 @@ if (strlen(trim($_GET["search_societe"])))
|
||||
{
|
||||
$sql .= " AND s.nom LIKE '%".$_GET["search_societe"]."%'";
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ if (!$user->rights->prelevement->bons->lire)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -128,18 +128,18 @@ print '</td><td valign="top" width="70%">';
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 .= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
|
||||
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
|
||||
if ( $db->query($sql) )
|
||||
|
||||
@ -38,7 +38,7 @@ $langs->load("withdrawals");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -192,7 +192,7 @@ class RejetPrelevement
|
||||
$emuser->fetch();
|
||||
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($fac->socidp);
|
||||
$soc->fetch($fac->socid);
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
|
||||
|
||||
|
||||
@ -57,12 +57,12 @@ $pagenext = $page + 1;
|
||||
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp='';
|
||||
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
|
||||
$socid='';
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ if ($_GET["propalid"] > 0)
|
||||
$propal->fetch($_GET['propalid']);
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($propal->socidp);
|
||||
$societe->fetch($propal->socid);
|
||||
|
||||
$head = propal_prepare_head($propal);
|
||||
dolibarr_fiche_head($head, 'compta', $langs->trans('Proposal'));
|
||||
@ -240,7 +240,7 @@ if ($_GET["propalid"] > 0)
|
||||
{
|
||||
print '<td colspan="2">';
|
||||
print $langs->trans("NoProject").'</td><td>';
|
||||
print '<a href=../projet/fiche.php?socidp='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>';
|
||||
print '<a href=../projet/fiche.php?socid='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
@ -357,7 +357,7 @@ if ($_GET["propalid"] > 0)
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
if (($objp->info_bits & 2) == 2)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socidp.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socid.'">';
|
||||
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
|
||||
print '</a>';
|
||||
if ($objp->description) print ' - '.nl2br($objp->description);
|
||||
@ -735,12 +735,12 @@ et non globalement
|
||||
$sql = "SELECT s.nom, s.idp, 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 && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp) $sql .= " AND s.idp = $socidp";
|
||||
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 ($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";
|
||||
@ -753,7 +753,7 @@ et non globalement
|
||||
|
||||
$propalstatic=new Propal($db);
|
||||
|
||||
print_barre_liste($langs->trans("Proposals"), $page, "propal.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste($langs->trans("Proposals"), $page, "propal.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
|
||||
$i = 0;
|
||||
$var=true;
|
||||
|
||||
@ -113,7 +113,7 @@ if ($result) {
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print "<td>".$langs->trans("Bills")." <a href=\"../facture.php?socidp=$objp->idp\">$objp->nom</td>\n";
|
||||
print "<td>".$langs->trans("Bills")." <a href=\"../facture.php?socid=$objp->idp\">$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";
|
||||
|
||||
@ -45,7 +45,7 @@ else {
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$modecompta = $conf->compta->mode;
|
||||
@ -95,7 +95,7 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql .= " FROM ".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";
|
||||
}
|
||||
if ($socidp) $sql .= " AND f.fk_soc = $socidp";
|
||||
if ($socid) $sql .= " AND f.fk_soc = $socid";
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= " ORDER BY dm";
|
||||
|
||||
@ -160,9 +160,9 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql .= " ON f.rowid = p.fk_facture_fourn";
|
||||
$sql .= " WHERE 1=1";
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ if (! $sortorder) $sortorder="asc";
|
||||
if (! $sortfield) $sortfield="name";
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0) $socidp = $user->societe_id;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
|
||||
|
||||
llxHeader();
|
||||
@ -91,7 +91,7 @@ else
|
||||
$sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_user_author = u.rowid";
|
||||
if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($socidp) $sql .= " AND f.fk_soc = $socidp";
|
||||
if ($socid) $sql .= " AND f.fk_soc = $socid";
|
||||
$sql .= " GROUP BY rowid";
|
||||
$sql .= " ORDER BY rowid";
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ if (! $sortorder) $sortorder="asc";
|
||||
if (! $sortfield) $sortfield="nom";
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0) $socidp = $user->societe_id;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
|
||||
|
||||
llxHeader();
|
||||
@ -90,7 +90,7 @@ else
|
||||
$sql .= " WHERE p.rowid = pf.fk_paiement AND pf.fk_facture = f.rowid AND f.fk_soc = s.idp";
|
||||
if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($socidp) $sql .= " AND f.fk_soc = $socidp";
|
||||
if ($socid) $sql .= " AND f.fk_soc = $socid";
|
||||
$sql .= " GROUP BY rowid";
|
||||
$sql .= " ORDER BY rowid";
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ function propals ($db, $year, $month) {
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print "<td><a href=\"comp.php?socidp=$objp->idp\">$objp->nom</a></td>\n";
|
||||
print "<td><a href=\"comp.php?socid=$objp->idp\">$objp->nom</a></td>\n";
|
||||
|
||||
print "<td><a href=\"../../comm/propal.php?propalid=$objp->propalid\">$objp->ref</a></td>\n";
|
||||
|
||||
@ -130,7 +130,7 @@ function factures ($db, $year, $month, $paye) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td><a href=\"comp.php?socidp=$objp->idp\">$objp->nom</a></td>\n";
|
||||
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";
|
||||
if ($objp->df > 0 )
|
||||
{
|
||||
@ -236,7 +236,7 @@ function pt ($db, $sql, $year) {
|
||||
}
|
||||
}
|
||||
|
||||
function ppt ($db, $year, $socidp)
|
||||
function ppt ($db, $year, $socid)
|
||||
{
|
||||
global $bc,$conf,$langs;
|
||||
print "<table width=\"100%\">";
|
||||
@ -252,9 +252,9 @@ function ppt ($db, $year, $socidp)
|
||||
$sql = "SELECT sum(f.price) as sum, round(date_format(f.datep,'%m')) as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in (1,2,4) AND date_format(f.datep,'%Y') = $year ";
|
||||
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY dm";
|
||||
@ -270,9 +270,9 @@ function ppt ($db, $year, $socidp)
|
||||
$sql .= " AND f.paye = 1";
|
||||
}
|
||||
$sql .= " AND date_format(f.datef,'%Y') = $year ";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
@ -300,7 +300,7 @@ function ppt ($db, $year, $socidp)
|
||||
}
|
||||
|
||||
$ayear = $year - 1;
|
||||
$acat = get_ca($db, $ayear, $socidp) - get_ca_propal($db, $ayear, $socidp);
|
||||
$acat = get_ca($db, $ayear, $socid) - get_ca_propal($db, $ayear, $socid);
|
||||
|
||||
|
||||
print "<tr class=\"total\"><td align=\"right\">Total :</td><td align=\"right\">".price($deltat)."</td></tr>";
|
||||
@ -324,7 +324,7 @@ llxHeader();
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$cyear = isset($_GET["year"])?$_GET["year"]:0;
|
||||
@ -332,7 +332,7 @@ if (! $cyear) { $cyear = strftime ("%Y", time()); }
|
||||
|
||||
print_fiche_titre("Chiffre d'Affaire transformé (prévu-réalisé)",($cyear?"<a href='comp.php?year=".($cyear-1)."'>".img_previous()."</a> Année $cyear <a href='comp.php?year=".($cyear+1)."'>".img_next()."</a>":""));
|
||||
|
||||
ppt($db, $cyear, $socidp);
|
||||
ppt($db, $cyear, $socid);
|
||||
|
||||
if ($details == 1)
|
||||
{
|
||||
|
||||
@ -37,7 +37,7 @@ llxHeader();
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$mode='recettes';
|
||||
@ -54,9 +54,9 @@ if ($conf->compta->mode != 'CREANCES-DETTES')
|
||||
{
|
||||
$sql .= " AND f.paye = 1";
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
@ -70,9 +70,9 @@ $sql .= " WHERE f.fk_statut = 1";
|
||||
if ($conf->compta->mode != 'CREANCES-DETTES') {
|
||||
$sql .= " AND f.paye = 1";
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ llxHeader();
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$mode='recettes';
|
||||
@ -74,7 +74,7 @@ function factures ($db, $year, $month, $paye)
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<TD><a href=\"comp.php?socidp=$objp->idp\">$objp->nom</a></TD>\n";
|
||||
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";
|
||||
if ($objp->df > 0 ) {
|
||||
print "<TD align=\"right\">".dolibarr_print_date($objp->df)."</TD>\n";
|
||||
@ -173,7 +173,7 @@ function pt ($db, $sql, $year) {
|
||||
}
|
||||
}
|
||||
|
||||
function ppt ($db, $year, $socidp)
|
||||
function ppt ($db, $year, $socid)
|
||||
{
|
||||
global $bc,$conf,$langs;
|
||||
print "<table width=\"100%\">";
|
||||
@ -193,9 +193,9 @@ function ppt ($db, $year, $socidp)
|
||||
if ($conf->compta->mode != 'CREANCES-DETTES') {
|
||||
$sql .= " AND f.paye = 1";
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
@ -210,9 +210,9 @@ function ppt ($db, $year, $socidp)
|
||||
if ($conf->compta->mode != 'CREANCES-DETTES') {
|
||||
$sql .= " AND f.paye = 1";
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
@ -251,7 +251,7 @@ function ppt ($db, $year, $socidp)
|
||||
|
||||
|
||||
$cyear = strftime ("%Y", time());
|
||||
ppt($db, $cyear, $socidp);
|
||||
ppt($db, $cyear, $socid);
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ else {
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$modecompta = $conf->compta->mode;
|
||||
@ -93,7 +93,7 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql .= " FROM ".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";
|
||||
}
|
||||
if ($socidp) $sql .= " AND f.fk_soc = $socidp";
|
||||
if ($socid) $sql .= " AND f.fk_soc = $socid";
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -315,9 +315,9 @@ if ($modecompta != 'CREANCES-DETTES')
|
||||
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, 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";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY f.facnumber,f.rowid,s.nom, s.idp, f.total_ttc";
|
||||
|
||||
@ -366,9 +366,9 @@ En attendant correction.
|
||||
WHERE p.fk_soc = s.idp
|
||||
AND p.fk_statut >=1
|
||||
AND p.facture =0";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY p.rowid";
|
||||
|
||||
|
||||
@ -21,13 +21,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
function get_ca_propal ($db, $year, $socidp)
|
||||
function get_ca_propal ($db, $year, $socid)
|
||||
{
|
||||
|
||||
$sql = "SELECT sum(f.price - f.remise) as sum FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in (1,2,4) AND date_format(f.datep, '%Y') = $year ";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -43,7 +43,7 @@ function get_ca_propal ($db, $year, $socidp)
|
||||
|
||||
}
|
||||
|
||||
function get_ca ($db, $year, $socidp)
|
||||
function get_ca ($db, $year, $socid)
|
||||
{
|
||||
|
||||
$sql = "SELECT sum(f.amount) as sum FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
@ -52,9 +52,9 @@ function get_ca ($db, $year, $socidp)
|
||||
$sql .= " AND f.paye = 1";
|
||||
}
|
||||
$sql .= " AND date_format(f.datef , '%Y') = $year ";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -27,7 +27,7 @@ require("./pre.inc.php");
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -98,9 +98,9 @@ print '<tr><td valign="top">';
|
||||
|
||||
$sql = "SELECT sum(f.price) as amount, date_format(f.datep,'%Y-%m') as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in $in";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
@ -110,9 +110,9 @@ print '</td><td valign="top">';
|
||||
|
||||
$sql = "SELECT sum(f.price) as amount, year(f.datep) as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in $in";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
|
||||
@ -122,9 +122,9 @@ print "<br>";
|
||||
|
||||
$sql = "SELECT sum(f.price) as amount, month(f.datep) as dm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in $in";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
$sql .= " AND f.fk_soc = $socid";
|
||||
}
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ $langs->load("suppliers");
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -91,9 +91,9 @@ if ($_POST["button_removefilter"])
|
||||
llxHeader();
|
||||
|
||||
$sql = "SELECT s.idp, s.nom, p.idp as cidp, p.name, p.firstname, p.email, p.phone, p.phone_mobile, p.fax";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = p.fk_soc";
|
||||
$sql.= " WHERE 1=1 ";
|
||||
|
||||
@ -101,7 +101,7 @@ if ($_GET["userid"]) // statut commercial
|
||||
{
|
||||
$sql .= " AND p.fk_user=".$_GET["userid"];
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -133,9 +133,9 @@ if ($sall)
|
||||
{
|
||||
$sql .= " AND (p.name like '%".addslashes($sall)."%' OR p.firstname like '%".addslashes($sall)."%' OR p.email like '%".addslashes($sall)."%') ";
|
||||
}
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
|
||||
if($_GET["view"] == "recent")
|
||||
|
||||
@ -48,7 +48,7 @@ $contratid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Protection restriction commercial
|
||||
@ -61,7 +61,7 @@ if ($contratid && (!$user->rights->commercial->client->voir || $user->societe_id
|
||||
{
|
||||
$sql .= " AND sc.fk_soc = c.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($user->societe_id > 0) $sql .= " AND c.fk_soc = ".$socidp;
|
||||
if ($user->societe_id > 0) $sql .= " AND c.fk_soc = ".$socid;
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
@ -240,7 +240,7 @@ if ($id > 0)
|
||||
if ($mesg) print $mesg;
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($contrat->socidp);
|
||||
$soc->fetch($contrat->socid);
|
||||
|
||||
$head = contract_prepare_head($contrat);
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ class Contrat extends CommonObject
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
var $socidp;
|
||||
var $socid;
|
||||
var $societe; // Objet societe
|
||||
|
||||
var $product;
|
||||
@ -302,7 +302,7 @@ class Contrat extends CommonObject
|
||||
|
||||
$this->fk_projet = $result["fk_projet"];
|
||||
|
||||
$this->socidp = $result["fk_soc"];
|
||||
$this->socid = $result["fk_soc"];
|
||||
$this->societe->fetch($result["fk_soc"]);
|
||||
|
||||
$this->db->free($resql);
|
||||
@ -470,7 +470,7 @@ class Contrat extends CommonObject
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat";
|
||||
// $sql.= ", fk_commercial_signature, fk_commercial_suivi";
|
||||
$sql.= " , ref)";
|
||||
$sql.= " VALUES (now(),".$this->socidp.",".$user->id;
|
||||
$sql.= " VALUES (now(),".$this->socid.",".$user->id;
|
||||
$sql.= ",".$this->db->idate($this->date_contrat);
|
||||
// $sql.= ",".($this->commercial_signature_id>=0?$this->commercial_signature_id:"null");
|
||||
// $sql.= ",".($this->commercial_suivi_id>=0?$this->commercial_suivi_id:"null");
|
||||
|
||||
@ -50,7 +50,7 @@ $contratid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Protection restriction commercial
|
||||
@ -63,7 +63,7 @@ if ($contratid && !$user->rights->commercial->client->voir)
|
||||
{
|
||||
$sql .= " AND sc.fk_soc = c.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($user->societe_id > 0) $sql .= " AND c.fk_soc = ".$socidp;
|
||||
if ($user->societe_id > 0) $sql .= " AND c.fk_soc = ".$socid;
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
@ -134,7 +134,7 @@ if ($_POST["action"] == 'add')
|
||||
|
||||
$contrat = new Contrat($db);
|
||||
|
||||
$contrat->socidp = $_POST["socidp"];
|
||||
$contrat->socid = $_POST["socid"];
|
||||
$contrat->date_contrat = $datecontrat;
|
||||
|
||||
$contrat->commercial_suivi_id = $_POST["commercial_suivi_id"];
|
||||
@ -154,7 +154,7 @@ if ($_POST["action"] == 'add')
|
||||
else {
|
||||
$mesg='<div class="error">'.$contrat->error.'</div>';
|
||||
}
|
||||
$_GET["socid"]=$_POST["socidp"];
|
||||
$_GET["socid"]=$_POST["socid"];
|
||||
$_GET["action"]='create';
|
||||
$action = '';
|
||||
}
|
||||
@ -330,7 +330,7 @@ if ($_GET["action"] == 'create')
|
||||
print '<form name="contrat" action="fiche.php" method="post">';
|
||||
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="socidp" value="'.$soc->id.'">'."\n";
|
||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
|
||||
print '<input type="hidden" name="remise_percent" value="0">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
@ -631,11 +631,11 @@ else
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET["action"] == "classer")
|
||||
{
|
||||
$html->form_project("fiche.php?id=$id",$contrat->socidp,$contrat->fk_projet,"projetid");
|
||||
$html->form_project("fiche.php?id=$id",$contrat->socid,$contrat->fk_projet,"projetid");
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project("fiche.php?id=$id",$contrat->socidp,$contrat->fk_projet,"none");
|
||||
$html->form_project("fiche.php?id=$id",$contrat->socid,$contrat->fk_projet,"none");
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
@ -971,7 +971,7 @@ else
|
||||
if ($contrat->statut > 0 && $user->rights->facture->creer)
|
||||
{
|
||||
$langs->load("bills");
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&contratid='.$contrat->id.'&socidp='.$contrat->societe->id.'">'.$langs->trans("CreateBill").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&contratid='.$contrat->id.'&socid='.$contrat->societe->id.'">'.$langs->trans("CreateBill").'</a>';
|
||||
}
|
||||
|
||||
$numclos=$contrat->array_detail(5); // Tableau des lignes au statut clos
|
||||
|
||||
@ -40,12 +40,12 @@ $page = isset($_GET["page"])?$_GET["page"]:$_POST["page"];
|
||||
$statut=isset($_GET["statut"])?$_GET["statut"]:1;
|
||||
|
||||
// Sécurité accés client
|
||||
$socidp='';
|
||||
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
|
||||
$socid='';
|
||||
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$staticcontrat=new Contrat($db);
|
||||
@ -106,13 +106,13 @@ $sql.= ' sum('.$db->ifsql("cd.statut=4 AND cd.date_fin_validite > sysdate()",1,0
|
||||
$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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp > 0) $sql .= " AND s.idp = ".$socidp;
|
||||
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.= " ORDER BY c.datec DESC";
|
||||
$sql.= " LIMIT $max";
|
||||
@ -169,13 +169,13 @@ print '<br>';
|
||||
|
||||
// Not activated services
|
||||
$sql = "SELECT cd.rowid as cid, c.ref, cd.statut, cd.label, cd.description as note, cd.fk_contrat, c.fk_soc, s.nom";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp > 0) $sql.= " AND s.idp = ".$socidp;
|
||||
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.= " ORDER BY cd.tms DESC";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
@ -223,12 +223,12 @@ print '<br>';
|
||||
$max=5;
|
||||
|
||||
$sql = "SELECT cd.rowid as cid, c.ref, cd.statut, cd.label, cd.description as note, cd.fk_contrat, c.fk_soc, s.nom";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socidp > 0) $sql.= " AND s.idp = ".$socidp;
|
||||
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.= " ORDER BY cd.tms DESC";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
|
||||
@ -41,7 +41,7 @@ $contratid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Protection restriction commercial
|
||||
@ -54,7 +54,7 @@ if ($contratid && (!$user->rights->commercial->client->voir || $user->societe_id
|
||||
{
|
||||
$sql .= " AND sc.fk_soc = c.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($user->societe_id > 0) $sql .= " AND c.fk_soc = ".$socidp;
|
||||
if ($user->societe_id > 0) $sql .= " AND c.fk_soc = ".$socid;
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
|
||||
@ -51,7 +51,7 @@ accessforbidden();
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ if ($id > 0)
|
||||
if ( $contrat->fetch($id) > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($contrat->socidp);
|
||||
$soc->fetch($contrat->socid);
|
||||
|
||||
$author = new User($db);
|
||||
$author->id = $contrat->user_author_id;
|
||||
|
||||
@ -31,7 +31,7 @@ require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php');
|
||||
if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
|
||||
|
||||
$socidp=isset($_GET["socidp"])?$_GET["socidp"]:isset($_POST["socidp"])?$_POST["socidp"]:"";
|
||||
$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
|
||||
|
||||
$user->getrights('contrat');
|
||||
if (!$user->rights->contrat->lire)
|
||||
@ -46,7 +46,7 @@ $contratid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
unset($_GET["action"]);
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Protection restriction commercial
|
||||
@ -59,7 +59,7 @@ if ($contratid && (!$user->rights->commercial->client->voir || $user->societe_id
|
||||
{
|
||||
$sql .= " AND sc.fk_soc = c.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
if ($user->societe_id > 0) $sql .= " AND c.fk_soc = ".$socidp;
|
||||
if ($user->societe_id > 0) $sql .= " AND c.fk_soc = ".$socid;
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
|
||||
@ -166,7 +166,7 @@ class Don
|
||||
$this->specimen=1;
|
||||
$this->nom = 'Doe';
|
||||
$this->prenom = 'John';
|
||||
$this->socidp = $socids[$socid];
|
||||
$this->socid = $socids[$socid];
|
||||
$this->date = time();
|
||||
$this->amount = 100;
|
||||
$this->public = 1;
|
||||
|
||||
@ -51,7 +51,7 @@ llxHeader("",'Dossier', $client);
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
if ($_GET["facid"])
|
||||
|
||||
@ -53,7 +53,7 @@ if (!$user->rights->commande->lire)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ if ($_GET["id"] > 0)
|
||||
$commande->loadExpeditions(1);
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
@ -206,7 +206,7 @@ if ($_GET["id"] > 0)
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socidp.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
|
||||
@ -268,11 +268,11 @@ if ($_GET["id"] > 0)
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'projetid');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socidp, $commande->projet_id, 'none');
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -710,7 +710,7 @@ class Expedition extends CommonObject
|
||||
$this->date = time();
|
||||
$this->entrepot_id = 0;
|
||||
$this->adresse_livraison_id = 0;
|
||||
$this->socidp = $socids[$socid];
|
||||
$this->socid = $socids[$socid];
|
||||
|
||||
$nbp = 5;
|
||||
$xnbp = 0;
|
||||
|
||||
@ -51,7 +51,7 @@ if (!$user->rights->expedition->lire)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
@ -191,7 +191,7 @@ if ($_GET["action"] == 'create')
|
||||
if ( $commande->fetch($_GET["commande_id"]))
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
@ -440,7 +440,7 @@ else
|
||||
$commande->fetch($expedition->commande_id);
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socidp);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id;
|
||||
|
||||
@ -51,15 +51,15 @@ 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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql .= " AND c.fk_soc = $socidp";
|
||||
$sql .= " AND c.fk_soc = $socid";
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -92,12 +92,12 @@ if ($resql)
|
||||
* Commandes à traiter
|
||||
*/
|
||||
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp) $sql .= " AND c.fk_soc = $socidp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
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.= " ORDER BY c.rowid ASC";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
@ -137,12 +137,12 @@ print '</td><td valign="top" width="70%">';
|
||||
* Commandes en traitement
|
||||
*/
|
||||
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp) $sql .= " AND c.fk_soc = $socidp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
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;
|
||||
$resql = $db->query($sql);
|
||||
if ( $resql )
|
||||
{
|
||||
@ -174,12 +174,12 @@ if ( $resql )
|
||||
* Expeditions à valider
|
||||
*/
|
||||
$sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
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 ($socidp) $sql .= " AND c.fk_soc = $socidp";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
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 .= " ORDER BY e.date_expedition DESC";
|
||||
$sql .= $db->plimit(5, 0);
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ if (!$user->rights->expedition->lire) accessforbidden();
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:"";
|
||||
@ -58,17 +58,17 @@ $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";
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
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 && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."commande as c";
|
||||
if ($socidp) $sql.=", ".MAIN_DB_PREFIX."commande as c";
|
||||
if ($user->rights->commercial->client->voir && !$socidp) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = e.fk_commande";
|
||||
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_add = " WHERE ";
|
||||
if ($socidp)
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= $sql_add . " e.fk_commande = c.rowid AND c.fk_soc = ".$socidp;
|
||||
$sql.= $sql_add . " e.fk_commande = c.rowid AND c.fk_soc = ".$socid;
|
||||
$sql_add = " AND ";
|
||||
}
|
||||
if ($_POST["sf_ref"])
|
||||
@ -76,7 +76,7 @@ if ($_POST["sf_ref"])
|
||||
$sql.= $sql_add . " e.ref like '%".addslashes($_POST["sf_ref"])."%'";
|
||||
$sql_add = " AND ";
|
||||
}
|
||||
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
|
||||
if (!$user->rights->commercial->client->voir && !$socid) //restriction
|
||||
{
|
||||
$sql .= $sql_add . " e.fk_commande = c.rowid AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -91,17 +91,17 @@ if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print_barre_liste($langs->trans('ListOfSendings'), $_GET["page"], "liste.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
|
||||
print_barre_liste($langs->trans('ListOfSendings'), $_GET["page"], "liste.php","&socid=$socid",$sortfield,$sortorder,'',$num);
|
||||
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Ref"),"liste.php","e.ref","","&socidp=$socidp",'width="15%"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),"liste.php","s.nom", "", "&socidp=$socidp",'width="25%" align="left"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Order"),"liste.php","c.ref", "", "&socidp=$socidp",'width="25%" align="left"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),"liste.php","e.date_expedition","","&socidp=$socidp", 'width="25%" align="right" colspan="2"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&socidp=$socidp",'width="10%" align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Ref"),"liste.php","e.ref","","&socid=$socid",'width="15%"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),"liste.php","s.nom", "", "&socid=$socid",'width="25%" align="left"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Order"),"liste.php","c.ref", "", "&socid=$socid",'width="25%" align="left"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),"liste.php","e.date_expedition","","&socid=$socid", 'width="25%" align="right" colspan="2"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&socid=$socid",'width="10%" align="center"',$sortfield);
|
||||
print "</tr>\n";
|
||||
$var=True;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user