/** * @description Set the an user as administrator. * @param mail Mail of the user. */ public function setAdmin($mail) { $this->output->writeln(sprintf('Set user <info>%s</info> as Administrator', $mail)); $admin_role = Role::get(1); if (empty($admin_role)) { $this->output->writeln('No Administrator role is in the database!'); return FALSE; } $user = new User(); $user->mail = $mail; $user->fetch('mail'); if (empty($user->getId())) { $this->output->writeln(sprintf('User with the mail address <info>%s</info> not found in in the database!', $mail)); return FALSE; } $ur = new UserRole(); $ur->user = $user; $ur->role = $admin_role; if (!$ur->save()) { $this->output->writeln('Unable to associate the administrator role!'); $this->output->writeln(print_r($ur->getErrors(), TRUE)); return FALSE; } $this->output->writeln('User associated!'); return TRUE; }
/** * Check authentication array and set error, errorcode, errorlabel * @param authentication Array * @param error * @param errorcode * @param errorlabel */ function check_authentication($authentication,&$error,&$errorcode,&$errorlabel) { global $db,$conf,$langs; $fuser=new User($db); if (! $error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY)) { $error++; $errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup'; } if (! $error) { $result=$fuser->fetch('',$authentication['login'],'',0); if ($result <= 0) $error++; // TODO Check password if ($error) { $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password'; } } if (! $error && ! empty($authentication['entity']) && ! is_numeric($authentication['entity'])) { $error++; $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter entity must be empty (or a numeric with id of instance if multicompany module is used)."; } return $fuser; }
/** * view_user * * @param mixed $id the unique identifier * * @access public * @return string */ function view_user($id) { $user = User::fetch($id); if (!$user) { throw new NotFoundException(); } return render('user_view.tpl', compact('user')); }
/** * Check authentication array and set error, errorcode, errorlabel * * @param array $authentication Array with authentication informations ('login'=>,'password'=>,'entity'=>,'dolibarrkey'=>) * @param int &$error Number of errors * @param string &$errorcode Error string code * @param string &$errorlabel Error string label * @return User Return user object identified by login/pass/entity into authentication array */ function check_authentication($authentication, &$error, &$errorcode, &$errorlabel) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_auto_user; $fuser = new User($db); if (!$error && $authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY) { $error++; $errorcode = 'BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel = 'Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup'; } if (!$error && !empty($authentication['entity']) && !is_numeric($authentication['entity'])) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter entity must be empty (or filled with numeric id of instance if multicompany module is used)."; } if (!$error) { $result = $fuser->fetch('', $authentication['login'], '', 0); if ($result < 0) { $error++; $errorcode = 'ERROR_FETCH_USER'; $errorlabel = 'A technical error occurs during fetch of user'; } else { if ($result == 0) { $error++; $errorcode = 'BAD_CREDENTIALS'; $errorlabel = 'Bad value for login or password'; } } if (!$error && $fuser->statut == 0) { $error++; $errorcode = 'ERROR_USER_DISABLED'; $errorlabel = 'This user has been locked or disabled'; } // Validation of login if (!$error) { $fuser->getrights(); // Load permission of user // Authentication mode if (empty($dolibarr_main_authentication)) { $dolibarr_main_authentication = 'http,dolibarr'; } // Authentication mode: forceuser if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) { $dolibarr_auto_user = '******'; } // Set authmode $authmode = explode(',', $dolibarr_main_authentication); include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; $login = checkLoginPassEntity($authentication['login'], $authentication['password'], $authentication['entity'], $authmode); if (empty($login)) { $error++; $errorcode = 'BAD_CREDENTIALS'; $errorlabel = 'Bad value for login or password'; } } } return $fuser; }
function topMenu() { $menu = array(); if (Permission::checkPermission(pow(2, 2))) { $user = new User((int) $_SESSION['user_id']); $user->fetch(); $menu[] = array('name' => $user->getNickname(), 'href' => 'user.php?user_id=' . $user->getUserId()); } return $menu; }
function ideaboxGetUserNom($id) { global $db, $langs; if (isset($id) && $id > 0) { $user = new User($db); $user->fetch($id); return $user->login; } else { return false; } }
static function getUser(&$PDOdb, $fk_category) { global $conf, $db; $Tab = $PDOdb->ExecuteAsArray("SELECT fk_user FROM " . MAIN_DB_PREFIX . "commercial_category WHERE fk_category=" . $fk_category); $TUser = array(); foreach ($Tab as &$row) { $u = new User($db); if ($u->fetch($row->fk_user) > 0) { $TUser[] = $u; } } return $TUser; }
function logout() { $model_user = new User($this->dbconn, $_SESSION['user']->id); $model_user->fetch(); $model_user->logout(); if (isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])) { setcookie("cookname", "", time() - 2592000, "/"); setcookie("cookpass", "", time() - 2592000, "/"); unset($_COOKIE['cookname']); unset($_COOKIE['cookpass']); } header('Location: index.php'); exit; }
/** * Връща модел за текущия потребител * * Ако има $_SESSION['user_id'] се връща модел, * с това което е успял да зареди, в противен случай * се връща false * * @return mixed: User|boolean */ static function loadCurrentUser() { if (empty($_SESSION['user_id'])) { return false; } if ($_SESSION['user_serialized']) { $_SESSION['user'] = unserialize($_SESSION['user_serialized']); $_SESSION['user']->dbconn = DBConn::getInstance()->conn; } else { $model_user = new User(DBConn::getInstance()->conn, $_SESSION['user_id']); $model_user->fetch(); $_SESSION['user'] = $model_user; $_SESSION['user_serialized'] = serialize($model_user); } return $_SESSION['user']; }
function index($id) { if ($id) { $user = new User($this->dbconn, $id); if ($user->fetch()) { $user->getTrees(); $this->smarty->Assign('user', $user); $this->display('User/profile.tpl'); } else { $_SESSION['system_error'] = _("Потребител с такова ID не съществува"); $this->display('Main/main.tpl'); } } else { $this->showList(); } }
function login() { include "user.php"; $obj = new User(); $uname = $_REQUEST['uname']; $pword = $_REQUEST['pword']; if (!$obj->getUser($uname, $pword)) { echo '{"result":0,"message": "failed to access user information"}'; } else { $row = $obj->fetch(); $_SESSION['userid'] = $row['id']; $_SESSION['username'] = $row['username']; $_SESSION['password'] = $row['password']; $_SESSION['permission'] = $row['permission']; getUserDetails(); } }
/** * Check access * * @return bool * @throws RestException */ public function __isAllowed() { global $db; $stored_key = ''; $userClass = Defaults::$userIdentifierClass; if (isset($_GET['api_key'])) { $sql = "SELECT u.login, u.datec, u.api_key, "; $sql .= " u.tms as date_modification, u.entity"; $sql .= " FROM " . MAIN_DB_PREFIX . "user as u"; $sql .= " WHERE u.api_key = '" . $db->escape($_GET['api_key']) . "'"; $result = $db->query($sql); if ($result) { if ($db->num_rows($result)) { $obj = $db->fetch_object($result); $login = $obj->login; $stored_key = $obj->api_key; } } else { throw new RestException(503, 'Error when fetching user api_key :' . $db->error_msg); } if ($stored_key != $_GET['api_key']) { $userClass::setCacheIdentifier($_GET['api_key']); return false; } $fuser = new User($db); if (!$fuser->fetch('', $login)) { throw new RestException(503, 'Error when fetching user :'******'external'; } if ($fuser->admin) { static::$role = 'admin'; } } else { throw new RestException(401, "Failed to login to API. No parameter 'api_key' provided"); //dol_syslog("Failed to login to API. No parameter key provided", LOG_DEBUG); //return false; } $userClass::setCacheIdentifier(static::$role); Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; return in_array(static::$role, (array) static::$requires) || static::$role == 'admin'; }
function updateUserUrls() { printfnq("Updating user URLs...\n"); // XXX: only update user URLs where out-of-date $user = new User(); if ($user->find()) { while ($user->fetch()) { printfv("Updating user {$user->nickname}..."); try { $profile = $user->getProfile(); updateProfileUrl($profile); } catch (Exception $e) { echo "Error updating URLs: " . $e->getMessage(); } printfv("DONE."); } } }
function _get_projet_cdp() { global $db; $TData = array(); $sql = 'SELECT COUNT(p.rowid) AS nombre, ec.fk_socpeople AS user FROM ' . MAIN_DB_PREFIX . 'projet p '; $sql .= 'INNER JOIN ' . MAIN_DB_PREFIX . 'element_contact ec ON ec.element_id=p.rowid '; $sql .= 'WHERE ec.fk_c_type_contact = 160 AND p.fk_statut=1 '; $sql .= 'GROUP BY ec.fk_socpeople '; $resql = $db->query($sql); if ($resql) { while ($line = $db->fetch_object($resql)) { $user = new User($db); $user->fetch($line->user); $TData[] = array("nom" => $user->firstname . ' ' . $user->lastname, "nombre" => $line->nombre); } } return $TData; }
/** * Handle the site * * @param mixed $object * @return boolean true on success, false on failure */ function handle($object) { $qm = QueueManager::get(); try { // Enqueue a summary for all users $user = new User(); $user->find(); while ($user->fetch()) { try { $qm->enqueue($user->id, 'usersum'); } catch (Exception $e) { common_log(LOG_WARNING, $e->getMessage()); continue; } } } catch (Exception $e) { common_log(LOG_WARNING, $e->getMessage()); } return true; }
function testAllUsers($filter) { $found = false; $offset = 0; $limit = 1000; do { $user = new User(); $user->orderBy('created'); $user->limit($offset, $limit); $found = $user->find(); if ($found) { while ($user->fetch()) { try { testUser($filter, $user); } catch (Exception $e) { printfnq("ERROR testing user %s\n: %s", $user->nickname, $e->getMessage()); } } $offset += $found; } } while ($found > 0); }
/** * Deny acces to a special section. Sets a deny message and forwards the user to the login site. * @author Clemens John <*****@*****.**> */ public static function denyAccess($permission = false, $owner = false) { // if $permission is != false, then get the Names of the Roles that are wrapped into $permission if ($permission) { $role_string = ""; foreach (Permission::getRolesByPermission($permission) as $key => $role) { if ($key) { $role_string .= ", "; } $role_string .= permission::getRoleNameByRoleNumber($role); } } if ($owner) { $user = new User($owner); $user->fetch(); } // prepare the "permission denied"-message for the user based on the combination of $permission and $owner if ($permission and !$owner) { $message[] = array("Auf diesen Bereich dürfen nur Benutzer mit den folgenden Rechten zugreifen: " . $role_string, 2); } elseif (!$permission and $owner) { $message[] = array("Auf diesen Bereich darf nur der Benutzer " . $user->getNickname() . " zugreifen.", 2); } elseif ($permission and $owner) { $message[] = array("Auf diesen Bereich dürfen nur der Benutzer " . $user->getNickname() . " oder Benutzer mit den folgenden Rechten zugreifen: " . $role_string, 2); } else { $message[] = array("Du darfst auf diesen Bereich nicht zugreifen.", 2); } // set the message Message::setMessage($message); // redirect the user to the last page he visited if it was a page inside netmon // if the page was not inside netmon, redirect to the default path if (!empty($_SESSION['last_page']) and $_SESSION['last_page'] != $_SESSION['current_page']) { header('Location: ' . $_SESSION['last_page']); } else { header('Location: ./'); } }
public function onStartUpgrade() { // This is a migration feature that will make sure we move // certain User preferences to the Profile_prefs table. // Introduced after commit b5fd2a048fc621ea05d756caba17275ab3dd0af4 // on Sun Jul 13 16:30:37 2014 +0200 $user = new User(); $user->whereAdd('emailnotifyfav IS NOT NULL'); if ($user->find()) { printfnq("Detected old User table (emailnotifyfav IS NOT NULL). Moving 'emailnotifyfav' property to Profile_prefs..."); // First we'll make sure Profile_prefs exists $schema = Schema::get(); $schema->ensureTable('profile_prefs', Profile_prefs::schemaDef()); // Make sure we have our own tables setup properly while ($user->fetch()) { $user->setPref('email', 'notify_fave', $user->emailnotifyfav); $orig = clone $user; $user->emailnotifyfav = 'null'; // flag this preference as migrated $user->update($orig); } printfnq("DONE.\n"); } }
/** * Called when a new user is registered. * * We find all users, and try to subscribe them to the new user, and * the new user to them. Exceptions (like silenced users or whatever) * are caught, logged, and ignored. * * @param Profile &$newProfile The new user's profile * @param User &$newUser The new user * * @return boolean hook value * */ function onEndUserRegister(&$newProfile, &$newUser) { $otherUser = new User(); $otherUser->whereAdd('id != ' . $newUser->id); if ($otherUser->find()) { while ($otherUser->fetch()) { $otherProfile = $otherUser->getProfile(); try { if (User_followeveryone_prefs::followEveryone($otherUser->id)) { Subscription::start($otherProfile, $newProfile); } Subscription::start($newProfile, $otherProfile); } catch (Exception $e) { common_log(LOG_WARNING, $e->getMessage()); continue; } } } $ufep = new User_followeveryone_prefs(); $ufep->user_id = $newUser->id; $ufep->followeveryone = true; $ufep->insert(); return true; }
print_fiche_titre($langs->trans("CreateADeliveryOrder")); if ($mesg) { print $mesg.'<br>'; } $commande = new Commande($db); $commande->livraison_array(); if ( $commande->fetch($_GET["commande_id"])) { $soc = new Societe($db); $soc->fetch($commande->socid); $author = new User($db); $author->fetch($commande->user_author_id); if (!$conf->expedition_bon->enabled && $conf->stock->enabled) { $entrepot = new Entrepot($db); } /* * Commande */ print '<form action="fiche.php" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="commande_id" value="'.$commande->id.'">'; if (!$conf->expedition_bon->enabled && $conf->stock->enabled) {
//print '<th>'.$langs->trans('TaskRessourceLinks').'</th>'; print '<th>' . $langs->trans('Projects') . '</th>'; print '<th>' . $langs->trans('Task') . '</th>'; print '<th>' . $langs->trans('DateStart') . '</th>'; print '<th>' . $langs->trans('DateEnd') . '</th>'; print '<th align="right">' . $langs->trans('PlannedWorkload') . '</th>'; print '<th align="right">' . $langs->trans("ProgressDeclared") . '</td>'; print '<th align="right">' . $langs->trans('TimeSpent') . '</th>'; print '<th align="right">' . $langs->trans("ProgressCalculated") . '</td>'; print '</tr>'; while ($i < $num && $i < $max) { $obj = $db->fetch_object($resql); $var = !$var; $username = ''; if ($obj->userid && $userstatic->id != $obj->userid) { $result = $userstatic->fetch($obj->userid); if (!$result) { $userstatic->id = 0; } } if ($userstatic->id) { $username = $userstatic->getNomUrl(0, 0); } print "<tr " . $bc[$var] . ">"; //print '<td>'.$username.'</td>'; print '<td>'; $projectstatic->id = $obj->projectid; $projectstatic->ref = $obj->ref; $projectstatic->title = $obj->title; print $projectstatic->getNomUrl(1, '', 16); //print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$obj->projectid.'">'.$obj->title.'</a>';
/** * Adds access rights * * @param int $reinitadminperms If 1, we also grant them to all admin users * @param int $force_entity Force current entity * * @return int Error count (0 if OK) */ function insert_permissions($reinitadminperms = 0, $force_entity = null) { global $conf, $user; $err = 0; $entity = !empty($force_entity) ? $force_entity : $conf->entity; // Test if module is activated $sql_del = "SELECT " . $this->db->decrypt('value') . " as value"; $sql_del .= " FROM " . MAIN_DB_PREFIX . "const"; $sql_del .= " WHERE " . $this->db->decrypt('name') . " = '" . $this->const_name . "'"; $sql_del .= " AND entity IN (0," . $entity . ")"; dol_syslog(get_class($this) . "::insert_permissions", LOG_DEBUG); $resql = $this->db->query($sql_del); if ($resql) { $obj = $this->db->fetch_object($resql); if ($obj !== null && !empty($obj->value) && !empty($this->rights)) { // If the module is active foreach ($this->rights as $key => $value) { $r_id = $this->rights[$key][0]; $r_desc = $this->rights[$key][1]; $r_type = isset($this->rights[$key][2]) ? $this->rights[$key][2] : ''; $r_def = $this->rights[$key][3]; $r_perms = $this->rights[$key][4]; $r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] : ''; $r_modul = $this->rights_class; if (empty($r_type)) { $r_type = 'w'; } // Search if perm already present $sql = "SELECT count(*) as nb FROM " . MAIN_DB_PREFIX . "rights_def"; $sql .= " WHERE id = " . $r_id . " AND entity = " . $entity; $resqlselect = $this->db->query($sql); $obj = $this->db->fetch_object($resqlselect); if ($obj->nb == 0) { if (dol_strlen($r_perms)) { if (dol_strlen($r_subperms)) { $sql = "INSERT INTO " . MAIN_DB_PREFIX . "rights_def"; $sql .= " (id, entity, libelle, module, type, bydefault, perms, subperms)"; $sql .= " VALUES "; $sql .= "(" . $r_id . "," . $entity . ",'" . $this->db->escape($r_desc) . "','" . $r_modul . "','" . $r_type . "'," . $r_def . ",'" . $r_perms . "','" . $r_subperms . "')"; } else { $sql = "INSERT INTO " . MAIN_DB_PREFIX . "rights_def"; $sql .= " (id, entity, libelle, module, type, bydefault, perms)"; $sql .= " VALUES "; $sql .= "(" . $r_id . "," . $entity . ",'" . $this->db->escape($r_desc) . "','" . $r_modul . "','" . $r_type . "'," . $r_def . ",'" . $r_perms . "')"; } } else { $sql = "INSERT INTO " . MAIN_DB_PREFIX . "rights_def "; $sql .= " (id, entity, libelle, module, type, bydefault)"; $sql .= " VALUES "; $sql .= "(" . $r_id . "," . $entity . ",'" . $this->db->escape($r_desc) . "','" . $r_modul . "','" . $r_type . "'," . $r_def . ")"; } $resqlinsert = $this->db->query($sql, 1); if (!$resqlinsert) { if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") { $this->error = $this->db->lasterror(); $err++; break; } else { dol_syslog(get_class($this) . "::insert_permissions record already exists", LOG_INFO); } } $this->db->free($resqlinsert); } $this->db->free($resqlselect); // If we want to init permissions on admin users if ($reinitadminperms) { if (!class_exists('User')) { require DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; } $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "user WHERE admin = 1"; dol_syslog(get_class($this) . "::insert_permissions Search all admin users", LOG_DEBUG); $resqlseladmin = $this->db->query($sql, 1); if ($resqlseladmin) { $num = $this->db->num_rows($resqlseladmin); $i = 0; while ($i < $num) { $obj2 = $this->db->fetch_object($resqlseladmin); dol_syslog(get_class($this) . "::insert_permissions Add permission to user id=" . $obj2->rowid); $tmpuser = new User($this->db); $tmpuser->fetch($obj2->rowid); if (!empty($tmpuser->id)) { $tmpuser->addrights($r_id); } $i++; } if (!empty($user->admin)) { // We reload permissions $user->clearrights(); $user->getrights(); } } else { dol_print_error($this->db); } } } } $this->db->free($resql); } else { $this->error = $this->db->lasterror(); $err++; } return $err; }
/** * Function to build pdf onto disk * * @param Object $object Object to generate * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $user, $langs, $conf, $mysoc, $db, $hookmanager; if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $nblignes = count($object->lines); // Loop on each lines to detect if there is at least one image to show $realpatharray = array(); if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) { for ($i = 0; $i < $nblignes; $i++) { if (empty($object->lines[$i]->fk_product)) { continue; } $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product . "/photos/"; $dir = $conf->product->dir_output . '/' . $pdir; $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { $filename = $obj['photo']; //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; $realpath = $dir . $filename; break; } if ($realpath) { $realpatharray[$i] = $realpath; } } } if (count($realpatharray) == 0) { $this->posxpicture = $this->posxtva; } if ($conf->facture->dir_output) { $object->fetch_thirdparty(); $deja_regle = $object->getSommePaiement(); $amount_credit_notes_included = $object->getSumCreditNotesUsed(); $amount_deposits_included = $object->getSumDepositsUsed(); // Definition of $dir and $file if ($object->specimen) { $dir = $conf->facture->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->facture->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); // Create pdf instance $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5; // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Invoice")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Invoice")); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0; $i < $nblignes; $i++) { if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } } if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxpicture += $this->postotalht - $this->posxdiscount; $this->posxtva += $this->postotalht - $this->posxdiscount; $this->posxup += $this->postotalht - $this->posxdiscount; $this->posxqty += $this->postotalht - $this->posxdiscount; $this->posxdiscount += $this->postotalht - $this->posxdiscount; //$this->postotalht; } // Situation invoice handling if ($object->situation_cycle_ref) { $this->situationinvoice = True; $progress_width = 14; $this->posxtva -= $progress_width; $this->posxup -= $progress_width; $this->posxqty -= $progress_width; $this->posxdiscount -= $progress_width; $this->posxprogress -= $progress_width; } // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; $tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10; $tab_height = 130; $tab_height_newpage = 150; // Incoterm $height_incoterms = 0; if ($conf->incoterm->enabled) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms = $nexY - $tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); $tab_top = $nexY + 6; $height_incoterms += 4; } } // Affiche notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { $salereparray = $object->thirdparty->getSalesRepresentatives($user); $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); if (!empty($salerepobj->signature)) { $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } } if ($notetoshow) { $tab_top = 88 + $height_incoterms; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); $height_note = $nexY - $tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; } else { $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; // Loop on each lines for ($i = 0; $i < $nblignes; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it $imglinesize = array(); if (!empty($realpatharray[$i])) { $imglinesize = pdf_getSizeForImage($realpatharray[$i]); } $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore = $pdf->getPage(); $showpricebeforepagebreak = 1; $posYAfterImage = 0; $posYAfterDescription = 0; // We start with Photo of product line if (isset($imglinesize['width']) && isset($imglinesize['height']) && $curY + $imglinesize['height'] > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) { $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; $showpricebeforepagebreak = 0; } if (isset($imglinesize['width']) && isset($imglinesize['height'])) { $curX = $this->posxpicture - 1; $pdf->Image($realpatharray[$i], $curX + ($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2, $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line $curX = $this->posxdesc - 1; $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) { $pdf->rollbackTransaction(true); $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; if ($posyafter > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) { if ($i == $nblignes - 1) { $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $pdf->setPage($pageposafter + 1); } } else { // We found a page break $showpricebeforepagebreak = 0; } } else { $pdf->commitTransaction(); } $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 3, $vat_rate, 0, 'R'); } // Unit price before discount $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); // Enough for 6 chars if ($conf->global->PRODUCT_USE_UNITS) { $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); } else { $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R'); } // Unit if ($conf->global->PRODUCT_USE_UNITS) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); } // Discount on line if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount - 2, $curY); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R'); } if ($this->situationinvoice) { // Situation progress $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxprogress, $curY); $pdf->MultiCell($this->postotalht - $this->posxprogress, 3, $progress, 0, 'R'); } // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress(); if ($prev_progress > 0) { if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { $tvaligne = $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } else { $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } } else { if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { $tvaligne = $object->lines[$i]->multicurrency_total_tva; } else { $tvaligne = $object->lines[$i]->total_tva; } } $localtax1ligne = $object->lines[$i]->total_localtax1; $localtax2ligne = $object->lines[$i]->total_localtax2; $localtax1_rate = $object->lines[$i]->localtax1_tx; $localtax2_rate = $object->lines[$i]->localtax2_tx; $localtax1_type = $object->lines[$i]->localtax1_type; $localtax2_type = $object->lines[$i]->localtax2_type; if ($object->remise_percent) { $tvaligne -= $tvaligne * $object->remise_percent / 100; } if ($object->remise_percent) { $localtax1ligne -= $localtax1ligne * $object->remise_percent / 100; } if ($object->remise_percent) { $localtax2ligne -= $localtax2ligne * $object->remise_percent / 100; } $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') && (!empty($localtax1_rate) || !empty($localtax2_rate))) { $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; } if ($localtax2_type && $localtax2ligne != 0) { $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; } if (($object->lines[$i]->info_bits & 0x1) == 0x1) { $vatrate .= '*'; } if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = ''; } $this->tva[$vatrate] += $tvaligne; if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; } // Add line if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < $nblignes - 1) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash' => 0)); } $nexY += 2; // Passe espace entre les lignes // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone infos $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } $pdf->Close(); $pdf->Output($file, 'F'); // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; // Pas d'erreur } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "FAC_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
$var = True; foreach ($prodcustprice->lines as $line) { print "<tr {$bc[$var]}>"; $staticprod = new Product($db); $staticprod->fetch($line->fk_product); print "<td>" . $staticprod->getNomUrl(1) . "</td>"; print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>"; print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>"; print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>"; print '<td align="right">' . price($line->price) . "</td>"; print '<td align="right">' . price($line->price_ttc) . "</td>"; print '<td align="right">' . price($line->price_min) . '</td>'; print '<td align="right">' . price($line->price_min_ttc) . '</td>'; // User $userstatic = new User($db); $userstatic->fetch($line->fk_user); print '<td align="right">'; print $userstatic->getLoginUrl(1); print '</td>'; // Todo Edit or delete button // Action if ($user->rights->produit->creer || $user->rights->service->creer) { print '<td align="right">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?action=delete_customer_price&socid=' . $soc->id . '&lineid=' . $line->id . '">'; print img_delete(); print '</a>'; print '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit_customer_price&socid=' . $soc->id . '&lineid=' . $line->id . '">'; print img_edit(); print '</a>'; print '<a href="' . $_SERVER["PHP_SELF"] . '?action=showlog_customer_price&socid=' . $soc->id . '&prodid=' . $line->fk_product . '">'; print img_info();
function getUserMembers() { // XXX: cache this $user = new User(); if (common_config('db', 'quote_identifiers')) { $user_table = '"user"'; } else { $user_table = 'user'; } $qry = 'SELECT id ' . 'FROM ' . $user_table . ' JOIN group_member ' . 'ON ' . $user_table . '.id = group_member.profile_id ' . 'WHERE group_member.group_id = %d '; $user->query(sprintf($qry, $this->id)); $ids = array(); while ($user->fetch()) { $ids[] = $user->id; } $user->free(); return $ids; }
function info($id) { $sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,"; $sql.= " c.tms as date_modification,"; $sql.= " fk_user_author, fk_user_cloture"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; $sql.= " WHERE c.rowid = ".$id; $result=$this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } if ($obj->fk_user_cloture) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_cloture); $this->user_cloture = $cuser; } $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); $this->date_cloture = $this->db->jdate($obj->date_cloture); } $this->db->free($result); } else { dol_print_error($this->db); } }
*/ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/usergroups.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/user/class/user.class.php'); $action=isset($_GET["action"])?$_GET["action"]:(isset($_POST["action"])?$_POST["action"]:""); $id=isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:""); $langs->load("companies"); $langs->load("members"); $langs->load("bills"); $langs->load("users"); $fuser = new User($db); $fuser->fetch($id); // If user is not user read and no permission to read other users, we stop if (($fuser->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden(); // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); if ($user->id == $_GET["id"]) // A user can always read its own card { $feature2=''; } $result = restrictedArea($user, 'user', $_GET["id"], '', $feature2);
/** * Show top header of page. * * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @return void */ function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs, $hookmanager; $outputlangs->load("main"); $outputlangs->load("trips"); $outputlangs->load("companies"); $default_font_size = pdf_getPDFFontSize($outputlangs); /* // ajout du fondu vert en bas de page à droite $image_fondue = $conf->mycompany->dir_output.'/fondu_vert_.jpg'; $pdf->Image($image_fondue,20,107,200,190); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); */ // Draft watermark if ($object->fk_statut == 1 && !empty($conf->global->EXPENSEREPORT_FREE_TEXT)) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_FREE_TEXT); } $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); $posy = $this->marge_haute; $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); // Logo $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { $height = pdf_getHeightForLogo($logo); $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { $pdf->SetTextColor(200, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } } else { $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } $pdf->SetFont('', 'B', $default_font_size + 4); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 6, $langs->trans("ExpenseReport"), 0, 'L'); $pdf->SetFont('', '', $default_font_size - 1); // Ref complete $posy += 8; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("Ref") . " : " . $object->ref, '', 'L'); // Date start period $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateStart") . " : " . ($object->date_debut > 0 ? dol_print_date($object->date_debut, "day", false, $outpulangs) : ''), '', 'L'); // Date end period $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $outputlangs->transnoentities("DateEnd") . " : " . ($object->date_fin > 0 ? dol_print_date($object->date_fin, "day", false, $outpulangs) : ''), '', 'L'); // Status Expense Report $posy += 6; $pdf->SetXY($posx, $posy); $pdf->SetFont('', 'B', 18); $pdf->SetTextColor(111, 81, 124); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $posx, 3, $object->getLibStatut(0), '', 'R'); // Sender properties $carac_emetteur = ''; $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->convToOutputCharset($this->emetteur->address); $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->convToOutputCharset($this->emetteur->zip) . ' ' . $outputlangs->convToOutputCharset($this->emetteur->town); $carac_emetteur .= "\n"; // Phone if ($this->emetteur->phone) { $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->transnoentities("Phone") . " : " . $outputlangs->convToOutputCharset($this->emetteur->phone); } // Fax if ($this->emetteur->fax) { $carac_emetteur .= ($carac_emetteur ? $this->emetteur->tel ? " - " : "\n" : '') . $outputlangs->transnoentities("Fax") . " : " . $outputlangs->convToOutputCharset($this->emetteur->fax); } // EMail if ($this->emetteur->email) { $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->transnoentities("Email") . " : " . $outputlangs->convToOutputCharset($this->emetteur->email); } // Web if ($this->emetteur->url) { $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->transnoentities("Web") . " : " . $outputlangs->convToOutputCharset($this->emetteur->url); } // Show sender $posy = 50; $posx = $this->marge_gauche; $hautcadre = 40; if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { $posx = 118; } // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("TripSociete") . " :", '', 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(224, 224, 224); $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0, 0, 60); // Show sender name $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); // Show sender information $pdf->SetXY($posx + 2, $posy + 8); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // Show recipient $posy = 50; $posx = 100; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', 'B', 8); $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF") . " :", 0, 'L'); $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); // Informations for trip (dates and users workflow) if ($object->fk_user_author > 0) { $userfee = new User($this->db); $userfee->fetch($object->fk_user_author); $posy += 3; $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', 10); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHOR") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation") . " : " . dol_print_date($object->date_create, "day", false, $outpulangs), 0, 'L'); } if ($object->fk_statut == 99) { if ($object->fk_user_refuse > 0) { $userfee = new User($this->db); $userfee->fetch($object->fk_user_refuse); $posy += 6; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("REFUSEUR") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_REFUS") . " : " . $outputlangs->convToOutputCharset($object->detail_refuse), 0, 'L'); $posy += 5; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_REFUS") . " : " . dol_print_date($object->date_refuse, "day", false, $outpulangs), 0, 'L'); } } else { if ($object->fk_statut == 4) { if ($object->fk_user_cancel > 0) { $userfee = new User($this->db); $userfee->fetch($object->fk_user_cancel); $posy += 6; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("CANCEL_USER") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_CANCEL") . " : " . $outputlangs->convToOutputCharset($object->detail_cancel), 0, 'L'); $posy += 5; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_CANCEL") . " : " . dol_print_date($object->date_cancel, "day", false, $outpulangs), 0, 'L'); } } else { if ($object->fk_user_approve > 0) { $userfee = new User($this->db); $userfee->fetch($object->fk_user_approve); $posy += 6; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("VALIDOR") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateApprove") . " : " . dol_print_date($object->date_approve, "day", false, $outpulangs), 0, 'L'); } } } if ($object->fk_statut == 6) { if ($object->fk_user_paid > 0) { $userfee = new User($this->db); $userfee->fetch($object->fk_user_paid); $posy += 6; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHORPAIEMENT") . " : " . dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_PAIEMENT") . " : " . dol_print_date($object->date_paiement, "day", false, $outpulangs), 0, 'L'); } } }
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')"; $filtercreditnote = "fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'"; } $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); $absolute_discount = price2num($absolute_discount, 'MT'); $absolute_creditnote = price2num($absolute_creditnote, 'MT'); $author = new User($db); if ($object->user_author) { $author->fetch($object->user_author); } $objectidnext = $object->getIdReplacingInvoice(); $head = facture_prepare_head($object); dol_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'), 0, 'bill'); $formconfirm = ''; // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { $text = $langs->trans('ConfirmConvertToReduc'); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); } // Confirmation to delete invoice if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteBill', $object->ref); $formquestion = array(); $qualified_for_stock_change = 0;
print '<div class="assignedtouser">'; print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '</div>'; if (in_array($user->id, array_keys($listofuserid))) { print '<div class="myavailability">'; print $langs->trans("MyAvailability") . ': ' . ($object->userassigned[$user->id]['transparency'] > 0 ? $langs->trans("Busy") : $langs->trans("Available")); // We show nothing if event is assigned to nobody print '</div>'; } print ' </td></tr>'; // Done by if ($conf->global->AGENDA_ENABLE_DONEBY) { print '<tr><td class="nowrap">' . $langs->trans("ActionDoneBy") . '</td><td colspan="3">'; if ($object->userdoneid > 0) { $tmpuser = new User($db); $tmpuser->fetch($object->userdoneid); print $tmpuser->getNomUrl(1); } print '</td></tr>'; } print '</table>'; print '<br><br>'; print '<table class="border" width="100%">'; // Third party - Contact if ($conf->societe->enabled) { print '<tr><td width="30%">' . $langs->trans("ActionOnCompany") . '</td><td>' . ($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : $langs->trans("None")); if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') { if ($object->thirdparty->fetch($object->thirdparty->id)) { print "<br>" . dol_print_phone($object->thirdparty->phone); } }