26 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
36 public $next_prev_filter =
"te.fournisseur = 1";
49 $this->fournisseur = 1;
60 $sql =
"SELECT rowid";
61 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
62 $sql .=
" WHERE cf.fk_soc = ".((int) $this->
id);
64 $resql = $this->db->query(
$sql);
66 $num = $this->db->num_rows($resql);
69 $row = $this->db->fetch_row($resql);
71 $this->single_open_commande = $row[0];
86 $sql =
"SELECT count(pfp.rowid) as nb";
87 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp";
88 $sql .=
" WHERE pfp.entity = ".$conf->entity;
89 $sql .=
" AND pfp.fk_soc = ".((int) $this->
id);
91 $resql = $this->db->query(
$sql);
93 $obj = $this->db->fetch_object($resql);
109 global $conf, $user, $hookmanager;
114 $sql =
"SELECT count(s.rowid) as nb";
115 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
116 if (empty($user->rights->societe->client->voir) && !$user->socid) {
117 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
118 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
121 $sql .=
" ".$clause.
" s.fournisseur = 1";
122 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
124 if (is_object($hookmanager)) {
125 $parameters = array();
126 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
127 $sql .= $hookmanager->resPrint;
130 $resql = $this->db->query(
$sql);
132 while ($obj = $this->db->fetch_object($resql)) {
133 $this->nb[
"suppliers"] = $obj->nb;
135 $this->db->free($resql);
139 $this->error = $this->db->error();
155 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie (label,visible,type)";
157 $sql .=
" ('".$this->db->escape($name).
"',1,1)";
159 dol_syslog(
"Fournisseur::CreateCategory", LOG_DEBUG);
160 $resql = $this->db->query(
$sql);
162 dol_syslog(
"Fournisseur::CreateCategory : Success");
165 $this->error = $this->db->lasterror();
166 dol_syslog(
"Fournisseur::CreateCategory : Failed (".$this->error.
")");
185 $sql =
"SELECT s.rowid, s.nom as name";
186 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
187 if (empty($user->rights->societe->client->voir) && !$user->socid) {
188 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
190 $sql .=
" WHERE s.fournisseur = 1";
191 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
192 if (empty($user->rights->societe->client->voir) && !$user->socid) {
193 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
196 $resql = $this->db->query(
$sql);
199 while ($obj = $this->db->fetch_object($resql)) {
200 $arr[$obj->rowid] = $obj->name;
204 $this->error = $this->db->lasterror();