28require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
38 public $next_prev_filter =
"(te.fournisseur:=:1)";
51 $this->fournisseur = 1;
73 public function fetch($rowid, $ref =
'', $ref_ext =
'', $barcode =
'', $idprof1 =
'', $idprof2 =
'', $idprof3 =
'', $idprof4 =
'', $idprof5 =
'', $idprof6 =
'', $email =
'', $ref_alias =
'', $is_client = 0, $is_supplier = 1)
75 return parent::fetch($rowid, $ref, $ref_ext, $barcode, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias, $is_client, $is_supplier);
87 $sql =
"SELECT rowid";
88 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
89 $sql .=
" WHERE cf.fk_soc = ".((int) $this->
id);
91 $resql = $this->db->query($sql);
93 $num = $this->db->num_rows($resql);
108 $sql =
"SELECT count(pfp.rowid) as nb";
109 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp";
110 $sql .=
" WHERE pfp.entity = ".$conf->entity;
111 $sql .=
" AND pfp.fk_soc = ".((int) $this->
id);
113 $resql = $this->db->query($sql);
115 $obj = $this->db->fetch_object($resql);
129 global
$conf, $user, $hookmanager;
134 $sql =
"SELECT count(s.rowid) as nb";
135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
136 if (!$user->hasRight(
"societe",
"client",
"voir") && !$user->socid) {
137 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
138 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
141 $sql .=
" ".$clause.
" s.fournisseur = 1";
142 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
144 if (is_object($hookmanager)) {
145 $parameters = array();
146 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
147 $sql .= $hookmanager->resPrint;
150 $resql = $this->db->query($sql);
152 while ($obj = $this->db->fetch_object($resql)) {
153 $this->nb[
"suppliers"] = $obj->nb;
155 $this->db->free($resql);
159 $this->error = $this->db->error();
175 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"categorie (label,visible,type)";
177 $sql .=
" ('".$this->db->escape($name).
"',1,1)";
179 dol_syslog(
"Fournisseur::CreateCategory", LOG_DEBUG);
180 $resql = $this->db->query($sql);
182 dol_syslog(
"Fournisseur::CreateCategory : Success");
185 $this->error = $this->db->lasterror();
186 dol_syslog(
"Fournisseur::CreateCategory : Failed (".$this->error.
")");
205 $sql =
"SELECT s.rowid, s.nom as name";
206 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
207 if (!$user->hasRight(
"societe",
"client",
"voir") && !$user->socid) {
208 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
210 $sql .=
" WHERE s.fournisseur = 1";
211 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
212 if (!$user->hasRight(
"societe",
"client",
"voir") && !$user->socid) {
213 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
216 $resql = $this->db->query($sql);
219 while ($obj = $this->db->fetch_object($resql)) {
220 $arr[$obj->rowid] = $obj->name;
224 $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.
getNbOfOrders()
Return nb of orders.
__construct($db)
Constructor.
loadStateBoard()
Load statistics indicators.
fetch($rowid, $ref='', $ref_ext='', $barcode='', $idprof1='', $idprof2='', $idprof3='', $idprof4='', $idprof5='', $idprof6='', $email='', $ref_alias='', $is_client=0, $is_supplier=1)
Load a third party from database into memory.
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=null, $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.