26require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
36 public $next_prev_filter =
"te.fournisseur = 1";
49 $this->fournisseur = 1;
62 $sql =
"SELECT rowid";
63 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
64 $sql .=
" WHERE cf.fk_soc = ".((int) $this->
id);
66 $resql = $this->db->query($sql);
68 $num = $this->db->num_rows($resql);
83 $sql =
"SELECT count(pfp.rowid) as nb";
84 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp";
85 $sql .=
" WHERE pfp.entity = ".$conf->entity;
86 $sql .=
" AND pfp.fk_soc = ".((int) $this->
id);
88 $resql = $this->db->query($sql);
90 $obj = $this->db->fetch_object($resql);
106 global $conf, $user, $hookmanager;
111 $sql =
"SELECT count(s.rowid) as nb";
112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
113 if (!$user->hasRight(
"societe",
"client",
"voir") && !$user->socid) {
114 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
115 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
118 $sql .=
" ".$clause.
" s.fournisseur = 1";
119 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
121 if (is_object($hookmanager)) {
122 $parameters = array();
123 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
124 $sql .= $hookmanager->resPrint;
127 $resql = $this->db->query($sql);
129 while ($obj = $this->db->fetch_object($resql)) {
130 $this->nb[
"suppliers"] = $obj->nb;
132 $this->db->free($resql);
136 $this->error = $this->db->error();
152 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie (label,visible,type)";
154 $sql .=
" ('".$this->db->escape($name).
"',1,1)";
156 dol_syslog(
"Fournisseur::CreateCategory", LOG_DEBUG);
157 $resql = $this->db->query($sql);
159 dol_syslog(
"Fournisseur::CreateCategory : Success");
162 $this->error = $this->db->lasterror();
163 dol_syslog(
"Fournisseur::CreateCategory : Failed (".$this->error.
")");
182 $sql =
"SELECT s.rowid, s.nom as name";
183 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
184 if (!$user->hasRight(
"societe",
"client",
"voir") && !$user->socid) {
185 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
187 $sql .=
" WHERE s.fournisseur = 1";
188 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
189 if (!$user->hasRight(
"societe",
"client",
"voir") && !$user->socid) {
190 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
193 $resql = $this->db->query($sql);
196 while ($obj = $this->db->fetch_object($resql)) {
197 $arr[$obj->rowid] = $obj->name;
201 $this->error = $this->db->lasterror();
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
Class to manage Dolibarr database access.
Class to manage suppliers.
nbOfProductRefs()
Returns number of ref prices (not number of products) for current supplier.
ListArray()
Return the suppliers list.
load_state_board()
Load statistics indicators.
getNbOfOrders()
Return nb of orders.
__construct($db)
Constructor.
CreateCategory($user, $name)
Create a supplier category.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.