/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $conf, $user, $langs, $db; $langs->load("boxes"); $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $thirdpartystatic = new Societe($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom, s.rowid as socid, s.datec, s.tms, s.status"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE s.fournisseur = 1"; $sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " ORDER BY s.tms DESC "; $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $datec = $db->jdate($objp->datec); $datem = $db->jdate($objp->tms); $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->nom, 'url' => DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day")); $this->info_box_contents[$i][3] = array('td' => 'align="right" width="18"', 'text' => $thirdpartystatic->LibStatut($objp->status, 3)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedSuppliers")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
/** * \brief Charge les donnees en memoire pour affichage ulterieur * \param $max Nombre maximum d'enregistrements a charger */ function loadBox($max=5) { global $user, $langs, $db, $conf; $this->max=$max; include_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); $thirdpartystatic=new Societe($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects",$max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom, s.rowid as socid, s.fk_stcomm, s.datec, s.tms, s.status"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.client IN (2, 3)"; $sql.= " AND s.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY s.tms DESC"; $sql.= $db->plimit($max, 0); dol_syslog("box_prospect::loadBox sql=".$sql,LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $prospectstatic=new Prospect($db); while ($i < $num) { $objp = $db->fetch_object($resql); $datec=$db->jdate($objp->datec); $datem=$db->jdate($objp->tms); $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->nom, 'url' => DOL_URL_ROOT."/comm/prospect/fiche.php?socid=".$objp->socid); $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day")); $this->info_box_contents[$i][3] = array('td' => 'align="right" width="18"', 'text' => str_replace('img ','img height="14" ',$prospectstatic->LibProspStatut($objp->fk_stcomm,3))); $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $thirdpartystatic->LibStatut($objp->status,3)); $i++; } if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedProspects")); } else { $this->info_box_contents[0][0] = array( 'td' => 'align="left"', 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql)); } } else { dol_syslog("box_prospect::loadBox not allowed de read this box content",LOG_ERR); $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
/** * Load data for box to show them later * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $thirdpartystatic = new Societe($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom as name, s.rowid as socid"; $sql .= ", s.code_client"; $sql .= ", s.client"; $sql .= ", s.code_fournisseur"; $sql .= ", s.fournisseur"; $sql .= ", s.logo"; $sql .= ", s.datec, s.tms, s.status"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE s.client IN (1, 3)"; $sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = {$user->societe_id}"; } $sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); dol_syslog(get_class($this) . "::loadBox", LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $line = 0; while ($line < $num) { $objp = $db->fetch_object($result); $datec = $db->jdate($objp->datec); $datem = $db->jdate($objp->tms); $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->code_client = $objp->code_client; $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; $thirdpartystatic->client = $objp->client; $thirdpartystatic->fournisseur = $objp->fournisseur; $thirdpartystatic->logo = $objp->logo; $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $thirdpartystatic->getNomUrl(1), 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day")); $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $thirdpartystatic->LibStatut($objp->status, 3)); $line++; } if ($num == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedCustomers")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }