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;
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 (!$user->hasRight(
"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 (!$user->hasRight(
"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 (!$user->hasRight(
"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();
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).
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.