Exemplo n.º 1
0
 if ($num) {
     dol_syslog("comm/mailing/fiche.php: nb of targets = " . $num, LOG_DEBUG);
     $now = dol_now();
     // Positionne date debut envoi
     $sql = "UPDATE " . MAIN_DB_PREFIX . "mailing SET date_envoi=" . $db->idate($now) . " WHERE rowid=" . $object->id;
     $resql2 = $db->query($sql);
     if (!$resql2) {
         dol_print_error($db);
     }
     // Loop on each email and send it
     $i = 0;
     while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) {
         $res = 1;
         $obj = $db->fetch_object($resql);
         // sendto en RFC2822
         $sendto = str_replace(',', ' ', dolGetFirstLastname($obj->firstname, $obj->lastname)) . " <" . $obj->email . ">";
         // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ...
         $other = explode(';', $obj->other);
         $tmpfield = explode('=', $other[0], 2);
         $other1 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
         $tmpfield = explode('=', $other[1], 2);
         $other2 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
         $tmpfield = explode('=', $other[2], 2);
         $other3 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
         $tmpfield = explode('=', $other[3], 2);
         $other4 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
         $tmpfield = explode('=', $other[4], 2);
         $other5 = isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0];
         // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions)
         $substitutionarray = array('__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, '__LASTNAME__' => $obj->lastname, '__FIRSTNAME__' => $obj->firstname, '__MAILTOEMAIL__' => '<a href="mailto:' . $obj->email . '">' . $obj->email . '</a>', '__OTHER1__' => $other1, '__OTHER2__' => $other2, '__OTHER3__' => $other3, '__OTHER4__' => $other4, '__OTHER5__' => $other5, '__CHECK_READ__' => '<img src="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-read.php?tag=' . $obj->tag . '&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" width="1" height="1" style="width:1px;height:1px" border="0"/>', '__UNSUBSCRIBE__' => '<a href="' . DOL_MAIN_URL_ROOT . '/public/emailing/mailing-unsubscribe.php?tag=' . $obj->tag . '&unsuscrib=1&securitykey=' . urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) . '" target="_blank">' . $langs->trans("MailUnsubcribe") . '</a>');
         if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
Exemplo n.º 2
0
 $var = true;
 $total_total_ht = 0;
 $total_total_ttc = 0;
 $total_total_tva = 0;
 $expensereportstatic = new ExpenseReport($db);
 if ($num > 0) {
     while ($i < min($num, $limit)) {
         $objp = $db->fetch_object($resql);
         $expensereportstatic->id = $objp->rowid;
         $expensereportstatic->ref = $objp->ref;
         $var = !$var;
         print "<tr " . $bc[$var] . ">";
         print '<td>' . $expensereportstatic->getNomUrl(1) . '</td>';
         print '<td align="center">' . ($objp->date_debut > 0 ? dol_print_date($objp->date_debut, 'day') : '') . '</td>';
         print '<td align="center">' . ($objp->date_fin > 0 ? dol_print_date($objp->date_fin, 'day') : '') . '</td>';
         print '<td align="left"><a href="' . DOL_URL_ROOT . '/user/card.php?id=' . $objp->id_user . '">' . img_object($langs->trans("ShowUser"), "user") . ' ' . dolGetFirstLastname($objp->firstname, $objp->lastname) . '</a></td>';
         print '<td align="right">' . price($objp->total_ht) . '</td>';
         print '<td align="right">' . price($objp->total_tva) . '</td>';
         print '<td align="right">' . price($objp->total_ttc) . '</td>';
         $expensereporttmp->status = $objp->status;
         print '<td align="right">';
         //print $objp->status;
         print $expensereporttmp->getLibStatut(5);
         print '</td>';
         print '<td></td>';
         print "</tr>\n";
         $total_total_ht = $total_total_ht + $objp->total_ht;
         $total_total_tva = $total_total_tva + $objp->total_tva;
         $total_total_ttc = $total_total_ttc + $objp->total_ttc;
         $i++;
     }
         }
     }
     // Define line content
     $outputlangs = new Translate('', $conf);
     $outputlangs->setDefaultLang(empty($obj->lang) ? $langs->defaultlang : $obj->lang);
     // By default language of sale representative
     $outputlangs->load("bills");
     $outputlangs->load("main");
     $outputlangs->load("contracts");
     $outputlangs->load("products");
     if (dol_strlen($obj->email)) {
         $message .= $outputlangs->trans("Contract") . " " . $obj->ref . ": " . $langs->trans("Service") . " " . dol_concatdesc($obj->plabel, $obj->description) . " (" . price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) . ") " . $obj->name . ", " . $outputlangs->trans("DateEndPlannedShort") . " " . dol_print_date($db->jdate($obj->date_fin_validite), 'day') . "\n\n";
         dol_syslog("email_expire_services_to_representatives.php: " . $obj->email);
         $foundtoprocess++;
     }
     print "Service to expire " . $obj->ref . ", label " . dol_concatdesc($obj->plabel, $obj->description) . ", due date " . dol_print_date($db->jdate($obj->date_fin_validite), 'day') . " (linked to company " . $obj->name . ", sale representative " . dolGetFirstLastname($obj->firstname, $obj->lastname) . ", email " . $obj->email . "): ";
     if (dol_strlen($obj->email)) {
         print "qualified.";
     } else {
         print "disqualified (no email).";
     }
     print "\n";
     unset($outputlangs);
     $total += $obj->total_ttc;
     $i++;
 }
 // Si il reste des envois en buffer
 if ($foundtoprocess) {
     if (dol_strlen($oldemail) && $oldemail != 'none') {
         envoi_mail($mode, $oldemail, $message, $total, $oldlang, $oldsalerepresentative, $duration_value);
     } else {
 /**
  *	Set withdrawal to transmited status
  *
  *	@param	User		$user		id of user
  *	@param 	timestamp	$date		date of action
  *	@param	string		$method		method of transmision to bank
  *	@return	int						>0 if OK, <0 if KO
  */
 function set_infotrans($user, $date, $method)
 {
     global $conf, $langs;
     $error = 0;
     dol_syslog(get_class($this) . "::set_infotrans Start", LOG_INFO);
     if ($this->db->begin()) {
         $sql = "UPDATE " . MAIN_DB_PREFIX . "prelevement_bons ";
         $sql .= " SET fk_user_trans = " . $user->id;
         $sql .= " , date_trans = '" . $this->db->idate($date) . "'";
         $sql .= " , method_trans = " . $method;
         $sql .= " , statut = 1";
         $sql .= " WHERE rowid = " . $this->id;
         $sql .= " AND entity = " . $conf->entity;
         $sql .= " AND statut = 0";
         if ($this->db->query($sql)) {
             $this->method_trans = $method;
             $langs->load('withdrawals');
             $subject = $langs->trans("InfoTransSubject", $this->ref);
             $message = $langs->trans("InfoTransMessage", $this->ref, dolGetFirstLastname($user->firstname, $user->lastname));
             $message .= $langs->trans("InfoTransData", price($this->amount), $this->methodes_trans[$this->method_trans], dol_print_date($date, 'day'));
             // TODO Call trigger to create a notification using notification module
         } else {
             dol_syslog(get_class($this) . "::set_infotrans Erreur 1", LOG_ERR);
             dol_syslog($this->db->error());
             $error++;
         }
         if ($error == 0) {
             $this->db->commit();
             return 0;
         } else {
             $this->db->rollback();
             dol_syslog(get_class($this) . "::set_infotrans ROLLBACK", LOG_ERR);
             return -1;
         }
     } else {
         dol_syslog(get_class($this) . "::set_infotrans Ouverture transaction SQL impossible", LOG_CRIT);
         return -2;
     }
 }
Exemplo n.º 5
0
 if ($resql) {
     $num = $db->num_rows($resql);
     $i = 0;
     while ($i < $num) {
         $obj = $db->fetch_object($resql);
         $event = new ActionComm($db);
         $event->id = $obj->rowid;
         // We put contact id in action id for birthdays events
         $datebirth = dol_stringtotime($obj->birthday, 1);
         //print 'ee'.$obj->birthday.'-'.$datebirth;
         $datearray = dol_getdate($datebirth, true);
         $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true);
         // For full day events, date are also GMT but they wont but converted during output
         $event->datef = $event->datep;
         $event->type_code = 'BIRTHDAY';
         $event->libelle = $langs->trans("Birthday") . ' ' . dolGetFirstLastname($obj->firstname, $obj->lastname);
         $event->percentage = 100;
         $event->fulldayevent = true;
         $event->date_start_in_calendar = $event->datep;
         $event->date_end_in_calendar = $event->datef;
         $event->ponctuel = 0;
         // Add an entry in actionarray for each day
         $daycursor = $event->date_start_in_calendar;
         $annee = date('Y', $daycursor);
         $mois = date('m', $daycursor);
         $jour = date('d', $daycursor);
         $loop = true;
         $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee);
         do {
             $eventarray[$daykey][] = $event;
             $daykey += 60 * 60 * 24;
Exemplo n.º 6
0
            print load_fiche_titre($title);
            // Lignes des titres
            print '<table class="noborder" width="100%">';
            print '<tr class="liste_titre">';
            print '<td>' . $langs->trans("Name") . '</td>';
            print '<td>' . $langs->trans("Login") . '</td>';
            print '<td>&nbsp;</td>';
            print "</tr>\n";
            $var = True;
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $var = !$var;
                print "<tr " . $bc[$var] . "><td>";
                print '<a href="' . DOL_URL_ROOT . '/user/card.php?id=' . $obj->rowid . '">';
                print img_object($langs->trans("ShowUser"), "user") . ' ';
                print dolGetFirstLastname($obj->firstname, $obj->lastname) . "\n";
                print '</a>';
                print '</td><td>' . $obj->login . '</td>';
                print '<td><a href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '&amp;commid=' . $obj->rowid . '">' . $langs->trans("Add") . '</a></td>';
                print '</tr>' . "\n";
                $i++;
            }
            print "</table>";
            $db->free($resql);
        } else {
            dol_print_error($db);
        }
    }
}
llxFooter();
$db->close();
Exemplo n.º 7
0
 /**
  *  Return select list for categories (to use in form search selectors)
  *
  *  @param	string	$selected     	Preselected value
  *  @param  string	$htmlname      	Name of combo list (example: 'search_sale')
  *  @param  User	$user           Object user
  *  @param	int		$showstatus		0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
  *  @param	int		$showempty		1=show also an empty value
  *  @param	string	$morecss		More CSS
  *  @return string					Html combo list code
  */
 function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '')
 {
     global $conf, $langs;
     $langs->load('users');
     $out = '';
     $nodatarole = '';
     // Enhance with select2
     if ($conf->use_javascript_ajax) {
         include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
         $comboenhancement = ajax_combobox($htmlname);
         if ($comboenhancement) {
             $out .= $comboenhancement;
             $nodatarole = $comboenhancement ? ' data-role="none"' : '';
         }
     }
     // Select each sales and print them in a select input
     $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '"' . $nodatarole . '>';
     if ($showempty) {
         $out .= '<option value="0">&nbsp;</option>';
     }
     // Get list of users allowed to be viewed
     $sql_usr = "******";
     $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u";
     $sql_usr .= " WHERE u.entity IN (0," . $conf->entity . ")";
     if (empty($user->rights->user->user->lire)) {
         $sql_usr .= " AND u.rowid = " . $user->id;
     }
     if (!empty($user->societe_id)) {
         $sql_usr .= " AND u.fk_soc = " . $user->societe_id;
     }
     // Add existing sales representatives of thirdparty of external user
     if (empty($user->rights->user->user->lire) && $user->societe_id) {
         $sql_usr .= " UNION ";
         $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut, u2.login";
         $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         $sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")";
         $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc=" . $user->societe_id;
     }
     $sql_usr .= " ORDER BY lastname ASC";
     //print $sql_usr;exit;
     $resql_usr = $this->db->query($sql_usr);
     if ($resql_usr) {
         while ($obj_usr = $this->db->fetch_object($resql_usr)) {
             $out .= '<option value="' . $obj_usr->rowid . '"';
             if ($obj_usr->rowid == $selected) {
                 $out .= ' selected';
             }
             $out .= '>';
             $out .= dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
             // Complete name with more info
             $moreinfo = 0;
             if (!empty($conf->global->MAIN_SHOW_LOGIN)) {
                 $out .= ($moreinfo ? ' - ' : ' (') . $obj_usr->login;
                 $moreinfo++;
             }
             if ($showstatus >= 0) {
                 if ($obj_usr->statut == 1 && $showstatus == 1) {
                     $out .= ($moreinfo ? ' - ' : ' (') . $langs->trans('Enabled');
                     $moreinfo++;
                 }
                 if ($obj_usr->statut == 0) {
                     $out .= ($moreinfo ? ' - ' : ' (') . $langs->trans('Disabled');
                     $moreinfo++;
                 }
             }
             $out .= $moreinfo ? ')' : '';
             $out .= '</option>';
         }
         $this->db->free($resql_usr);
     } else {
         dol_print_error($this->db);
     }
     $out .= '</select>';
     return $out;
 }
Exemplo n.º 8
0
 /**
  *  Fonction qui donne les droits redacteurs dans spip
  *
  *	@param	Adherent	$object		Object with data (->firstname, ->lastname, ->email and ->login)
  *  @return	int					=0 if KO, >0 if OK
  */
 function add_to_spip($object)
 {
     dol_syslog(get_class($this) . "::add_to_spip");
     if ($this->isSpipEnabled()) {
         if ($this->checkSpipConfig()) {
             $mydb = $this->connectSpip();
             if ($mydb) {
                 require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
                 $mdpass = dol_hash($object->pass);
                 $htpass = crypt($object->pass, makesalt());
                 $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"" . dolGetFirstLastname($object->firstname, $object->lastname) . "\",\"" . $object->email . "\",\"" . $object->login . "\",\"{$mdpass}\",\"{$htpass}\",FLOOR(32000*RAND()),\"1comite\")";
                 $result = $mydb->query($query);
                 $mydb->close();
                 if ($result) {
                     return 1;
                 } else {
                     $this->error = $mydb->lasterror();
                 }
             } else {
                 $this->error = 'Failed to connect to SPIP';
             }
         } else {
             $this->error = 'BadSPIPConfiguration';
         }
     } else {
         $this->error = 'SPIPNotEnabled';
     }
     return 0;
 }
Exemplo n.º 9
0
    /**
     *  Return property of contact from its id
     *
     *  @param	int		$rowid      id of contact
     *  @param  string	$mode       'email' or 'mobile'
     *  @return string  			email of contact
     */
    function contact_get_property($rowid,$mode)
    {
        $contact_property='';

        if (empty($rowid)) return '';

        $sql = "SELECT rowid, email, phone_mobile, lastname, firstname";
        $sql.= " FROM ".MAIN_DB_PREFIX."socpeople";
        $sql.= " WHERE rowid = '".$rowid."'";

        $resql=$this->db->query($sql);
        if ($resql)
        {
            $nump = $this->db->num_rows($resql);

            if ($nump)
            {
                $obj = $this->db->fetch_object($resql);

                if ($mode == 'email') $contact_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">";
                else if ($mode == 'mobile') $contact_property = $obj->phone_mobile;
            }
            return $contact_property;
        }
        else
        {
            dol_print_error($this->db);
        }

    }
Exemplo n.º 10
0
     $object = new Societe($db);
     $object->fetch($socid);
     $res = $object->setValueFrom('localtax2_value', $value);
 }
 // Add new or update third party
 if (!GETPOST('getcustomercode') && !GETPOST('getsuppliercode') && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) {
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     if ($action == 'update') {
         $ret = $object->fetch($socid);
         $object->oldcopy = dol_clone($object);
     } else {
         $object->canvas = $canvas;
     }
     if (GETPOST("private") == 1) {
         $object->particulier = GETPOST("private");
         $object->name = dolGetFirstLastname(GETPOST('firstname', 'alpha'), GETPOST('nom', 'alpha') ? GETPOST('nom', 'alpha') : GETPOST('name', 'alpha'));
         $object->civility_id = GETPOST('civility_id', 'int');
         // Add non official properties
         $object->name_bis = GETPOST('name', 'alpha') ? GETPOST('name', 'alpha') : GETPOST('nom', 'alpha');
         $object->firstname = GETPOST('firstname', 'alpha');
     } else {
         $object->name = GETPOST('name', 'alpha') ? GETPOST('name', 'alpha') : GETPOST('nom', 'alpha');
     }
     $object->address = GETPOST('address', 'alpha');
     $object->zip = GETPOST('zipcode', 'alpha');
     $object->town = GETPOST('town', 'alpha');
     $object->country_id = GETPOST('country_id', 'int');
     $object->state_id = GETPOST('state_id', 'int');
     $object->skype = GETPOST('skype', 'alpha');
     $object->phone = GETPOST('phone', 'alpha');
     $object->fax = GETPOST('fax', 'alpha');
Exemplo n.º 11
0
 /**
  *	Return full name (civility+' '+name+' '+lastname)
  *
  *	@param	Translate	$langs			Language object for translation of civility
  *	@param	int			$option			0=No option, 1=Add civility
  * 	@param	int			$nameorder		-1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname
  * 	@param	int			$maxlen			Maximum length
  * 	@return	string						String with full name
  */
 function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0)
 {
     //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n";
     $lastname = $this->lastname;
     $firstname = $this->firstname;
     if (empty($lastname)) {
         $lastname = isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : ''));
     }
     $ret = '';
     if ($option && $this->civility_id) {
         if ($langs->transnoentitiesnoconv("Civility" . $this->civility_id) != "Civility" . $this->civility_id) {
             $ret .= $langs->transnoentitiesnoconv("Civility" . $this->civility_id) . ' ';
         } else {
             $ret .= $this->civility_id . ' ';
         }
     }
     $ret .= dolGetFirstLastname($firstname, $lastname, $nameorder);
     return dol_trunc($ret, $maxlen);
 }
Exemplo n.º 12
0
 /**
  *		Export events from database into a cal file.
  *
  *		@param	string		$format			'vcal', 'ical/ics', 'rss'
  *		@param	string		$type			'event' or 'journal'
  *		@param	int			$cachedelay		Do not rebuild file if date older than cachedelay seconds
  *		@param	string		$filename		Force filename
  *		@param	array		$filters		Array of filters
  *		@return int     					<0 if error, nb of events in new file if ok
  */
 function build_exportfile($format, $type, $cachedelay, $filename, $filters)
 {
     global $conf, $langs, $dolibarr_main_url_root, $mysoc;
     require_once DOL_DOCUMENT_ROOT . "/core/lib/xcal.lib.php";
     require_once DOL_DOCUMENT_ROOT . "/core/lib/date.lib.php";
     require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
     dol_syslog(get_class($this) . "::build_exportfile Build export file format=" . $format . ", type=" . $type . ", cachedelay=" . $cachedelay . ", filename=" . $filename . ", filters size=" . count($filters), LOG_DEBUG);
     // Check parameters
     if (empty($format)) {
         return -1;
     }
     // Clean parameters
     if (!$filename) {
         $extension = 'vcs';
         if ($format == 'ical') {
             $extension = 'ics';
         }
         $filename = $format . '.' . $extension;
     }
     // Create dir and define output file (definitive and temporary)
     $result = dol_mkdir($conf->agenda->dir_temp);
     $outputfile = $conf->agenda->dir_temp . '/' . $filename;
     $result = 0;
     $buildfile = true;
     $login = '';
     $logina = '';
     $logind = '';
     $logint = '';
     $now = dol_now();
     if ($cachedelay) {
         $nowgmt = dol_now();
         include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
         if (dol_filemtime($outputfile) > $nowgmt - $cachedelay) {
             dol_syslog(get_class($this) . "::build_exportfile file " . $outputfile . " is not older than now - cachedelay (" . $nowgmt . " - " . $cachedelay . "). Build is canceled");
             $buildfile = false;
         }
     }
     if ($buildfile) {
         // Build event array
         $eventarray = array();
         $sql = "SELECT a.id,";
         $sql .= " a.datep,";
         // Start
         $sql .= " a.datep2,";
         // End
         $sql .= " a.durationp,";
         // deprecated
         $sql .= " a.datec, a.tms as datem,";
         $sql .= " a.label, a.code, a.note, a.fk_action as type_id,";
         $sql .= " a.fk_soc,";
         $sql .= " a.fk_user_author, a.fk_user_mod,";
         $sql .= " a.fk_user_action,";
         $sql .= " a.fk_contact, a.percent as percentage,";
         $sql .= " a.fk_element, a.elementtype,";
         $sql .= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,";
         $sql .= " u.firstname, u.lastname,";
         $sql .= " s.nom as socname,";
         $sql .= " c.id as type_id, c.code as type_code, c.libelle";
         $sql .= " FROM (" . MAIN_DB_PREFIX . "c_actioncomm as c, " . MAIN_DB_PREFIX . "actioncomm as a)";
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on u.rowid = a.fk_user_author";
         // Link to get author of event for export
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s on s.rowid = a.fk_soc";
         // We must filter on assignement table
         if ($filters['logint'] || $filters['login']) {
             $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar";
         }
         $sql .= " WHERE a.fk_action=c.id";
         $sql .= " AND a.entity IN (" . getEntity('actioncomm', 1) . ")";
         foreach ($filters as $key => $value) {
             if ($key == 'notolderthan' && $value != '') {
                 $sql .= " AND a.datep >= '" . $this->db->idate($now - $value * 24 * 60 * 60) . "'";
             }
             if ($key == 'year') {
                 $sql .= " AND a.datep BETWEEN '" . $this->db->idate(dol_get_first_day($value, 1)) . "' AND '" . $this->db->idate(dol_get_last_day($value, 12)) . "'";
             }
             if ($key == 'id') {
                 $sql .= " AND a.id=" . (is_numeric($value) ? $value : 0);
             }
             if ($key == 'idfrom') {
                 $sql .= " AND a.id >= " . (is_numeric($value) ? $value : 0);
             }
             if ($key == 'idto') {
                 $sql .= " AND a.id <= " . (is_numeric($value) ? $value : 0);
             }
             if ($key == 'project') {
                 $sql .= " AND a.fk_project=" . (is_numeric($value) ? $value : 0);
             }
             // We must filter on assignement table
             if ($key == 'logint' || $key == 'login') {
                 $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
             }
             if ($key == 'logina') {
                 $logina = $value;
                 $userforfilter = new User($this->db);
                 $result = $userforfilter->fetch('', $value);
                 $sql .= " AND a.fk_user_author = " . $userforfilter->id;
             }
             if ($key == 'logint' || $key == 'login') {
                 $logint = $value;
                 $userforfilter = new User($this->db);
                 $result = $userforfilter->fetch('', $value);
                 $sql .= " AND ar.fk_element = " . $userforfilter->id;
             }
         }
         $sql .= " AND a.datep IS NOT NULL";
         // To exclude corrupted events and avoid errors in lightning/sunbird import
         $sql .= " ORDER by datep";
         //print $sql;exit;
         dol_syslog(get_class($this) . "::build_exportfile select events", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if ($resql) {
             // Note: Output of sql request is encoded in $conf->file->character_set_client
             // This assignment in condition is not a bug. It allows walking the results.
             while ($obj = $this->db->fetch_object($resql)) {
                 $qualified = true;
                 // 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author'
                 $event = array();
                 $event['uid'] = 'dolibarragenda-' . $this->db->database_name . '-' . $obj->id . "@" . $_SERVER["SERVER_NAME"];
                 $event['type'] = $type;
                 $datestart = $this->db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : $conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
                 $dateend = $this->db->jdate($obj->datep2) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : $conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
                 $duration = $datestart && $dateend ? $dateend - $datestart : 0;
                 $event['summary'] = $obj->label . ($obj->socname ? " (" . $obj->socname . ")" : "");
                 $event['desc'] = $obj->note;
                 $event['startdate'] = $datestart;
                 $event['enddate'] = $dateend;
                 // Not required with type 'journal'
                 $event['duration'] = $duration;
                 // Not required with type 'journal'
                 $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname);
                 $event['priority'] = $obj->priority;
                 $event['fulldayevent'] = $obj->fulldayevent;
                 $event['location'] = $obj->location;
                 $event['transparency'] = $obj->transparency > 0 ? 'OPAQUE' : 'TRANSPARENT';
                 // OPAQUE (busy) or TRANSPARENT (not busy)
                 $event['punctual'] = $obj->punctual;
                 $event['category'] = $obj->libelle;
                 // libelle type action
                 // Define $urlwithroot
                 $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
                 $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
                 // This is to use external domain name found into config file
                 //$urlwithroot=DOL_MAIN_URL_ROOT;						// This is to use same domain name than current
                 $url = $urlwithroot . '/comm/action/card.php?id=' . $obj->id;
                 $event['url'] = $url;
                 $event['created'] = $this->db->jdate($obj->datec) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : $conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
                 $event['modified'] = $this->db->jdate($obj->datem) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : $conf->global->AGENDA_EXPORT_FIX_TZ * 3600);
                 if ($qualified && $datestart) {
                     $eventarray[$datestart] = $event;
                 }
             }
         } else {
             $this->error = $this->db->lasterror();
             return -1;
         }
         $langs->load("agenda");
         // Define title and desc
         $more = '';
         if ($login) {
             $more = $langs->transnoentities("User") . ' ' . $login;
         }
         if ($logina) {
             $more = $langs->transnoentities("ActionsAskedBy") . ' ' . $logina;
         }
         if ($logint) {
             $more = $langs->transnoentities("ActionsToDoBy") . ' ' . $logint;
         }
         if ($logind) {
             $more = $langs->transnoentities("ActionsDoneBy") . ' ' . $logind;
         }
         if ($more) {
             $title = 'Dolibarr actions ' . $mysoc->name . ' - ' . $more;
             $desc = $more;
             $desc .= ' (' . $mysoc->name . ' - built by Dolibarr)';
         } else {
             $title = 'Dolibarr actions ' . $mysoc->name;
             $desc = $langs->transnoentities('ListOfActions');
             $desc .= ' (' . $mysoc->name . ' - built by Dolibarr)';
         }
         // Create temp file
         $outputfiletmp = tempnam($conf->agenda->dir_temp, 'tmp');
         // Temporary file (allow call of function by different threads
         @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK));
         // Write file
         if ($format == 'vcal') {
             $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
         }
         if ($format == 'ical') {
             $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp);
         }
         if ($format == 'rss') {
             $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp);
         }
         if ($result >= 0) {
             if (dol_move($outputfiletmp, $outputfile, 0, 1)) {
                 $result = 1;
             } else {
                 $this->error = 'Failed to rename ' . $outputfiletmp . ' into ' . $outputfile;
                 dol_syslog(get_class($this) . "::build_exportfile " . $this->error, LOG_ERR);
                 dol_delete_file($outputfiletmp, 0, 1);
                 $result = -1;
             }
         } else {
             dol_syslog(get_class($this) . "::build_exportfile build_xxxfile function fails to for format=" . $format . " outputfiletmp=" . $outputfile, LOG_ERR);
             dol_delete_file($outputfiletmp, 0, 1);
             $langs->load("errors");
             $this->error = $langs->trans("ErrorFailToCreateFile", $outputfile);
         }
     }
     return $result;
 }
    if ($num) {
        print "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
        print '<TR>';
        print "<td>" . $langs->trans("Name") . " / " . $langs->trans("Company") . "</td>";
        print "<td>Date</td>";
        print "<td align=\"right\">" . $langs->trans("Amount") . "</TD>";
        print "</TR>\n";
        $var = True;
        $bc[1] = 'bgcolor="#f5f5f5"';
        $bc[0] = 'bgcolor="#f0f0f0"';
        while ($i < $num) {
            $objp = $db->fetch_object($resql);
            $var = !$var;
            print "<tr " . $bc[$var] . ">";
            if ($objp->public) {
                print "<td>" . dolGetFirstLastname($objp->firstname, $objp->lastname) . " " . $objp->societe . "</td>\n";
            } else {
                print "<td>Anonyme Anonyme</td>\n";
            }
            print "<td>" . dol_print_date($db->jdate($objp->datedon)) . "</td>\n";
            print '<td align="right">' . number_format($objp->amount, 2, '.', ' ') . ' ' . $langs->trans("Currency" . $conf->currency) . '</td>';
            print "</tr>";
            $i++;
        }
        print "</table>";
    } else {
        print "Aucun don publique";
    }
} else {
    dol_print_error($db);
}
Exemplo n.º 14
0
     }
     // From
     $expediteur = new User($db);
     $expediteur->fetch($cp->fk_validator);
     $emailFrom = $expediteur->email;
     // Subject
     $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
     if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
         $societeName = $conf->global->MAIN_APPLICATION_TITLE;
     }
     $subject = $societeName . " - " . $langs->transnoentitiesnoconv("HolidaysCanceled");
     // Content
     $message = $langs->transnoentitiesnoconv("Hello") . " " . $destinataire->firstname . ",\n";
     $message .= "\n";
     $message .= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($cp->date_debut, 'day'), dol_print_date($cp->date_fin, 'day')) . "\n";
     $message .= "- " . $langs->transnoentitiesnoconv("ModifiedBy") . " : " . dolGetFirstLastname($expediteur->firstname, $expediteur->lastname) . "\n";
     $message .= "- " . $langs->transnoentitiesnoconv("Link") . " : " . $dolibarr_main_url_root . "/holiday/fiche.php?id=" . $cp->rowid . "\n\n";
     $message .= "\n";
     $mail = new CMailFile($subject, $emailTo, $emailFrom, $message);
     // Envoi du mail
     $result = $mail->sendfile();
     if (!$result) {
         header('Location: fiche.php?id=' . $_GET['id'] . '&error=mail&error_content=' . $mail->error);
         exit;
     }
     header('Location: fiche.php?id=' . $_GET['id']);
     exit;
 } else {
     // Sinon on affiche le formulaire de demande avec le message d'erreur SQL
     header('Location: fiche.php?id=' . $_GET['id'] . '&error=SQL_Create&msg=' . $cp->error);
     exit;
Exemplo n.º 15
0
 /**
  *  Check if notification are active for couple action/company.
  * 	If yes, send mail and save trace into llx_notify.
  *
  * 	@param	string	$notifcode		Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
  * 	@param	Object	$object			Object the notification deals on
  *	@return	int						<0 if KO, or number of changes if OK
  */
 function send($notifcode, $object)
 {
     global $user, $conf, $langs, $mysoc, $dolibarr_main_url_root;
     include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     dol_syslog(get_class($this) . "::send notifcode=" . $notifcode . ", object=" . $object->id);
     $langs->load("other");
     // Define $urlwithroot
     $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
     $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
     // This is to use external domain name found into config file
     //$urlwithroot=DOL_MAIN_URL_ROOT;						// This is to use same domain name than current
     // Define some vars
     $application = $mysoc->name;
     //if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
     $replyto = $conf->notification->email_from;
     $filename = basename($file);
     $mimefile = dol_mimetype($file);
     $object_type = '';
     $link = '';
     $num = 0;
     if (!in_array($notifcode, array('BILL_VALIDATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', 'FICHINTER_VALIDATE', 'ORDER_SUPPLIER_VALIDATE', 'ORDER_SUPPLIER_APPROVE', 'ORDER_SUPPLIER_REFUSE', 'SHIPPING_VALIDATE'))) {
         return 0;
     }
     $oldref = empty($object->oldref) ? $object->ref : $object->oldref;
     $newref = empty($object->newref) ? $object->ref : $object->newref;
     // Check notification per third party
     $sql = "SELECT s.nom, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
     $sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
     $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as c,";
     $sql .= " " . MAIN_DB_PREFIX . "c_action_trigger as a,";
     $sql .= " " . MAIN_DB_PREFIX . "notify_def as n,";
     $sql .= " " . MAIN_DB_PREFIX . "societe as s";
     $sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
     $sql .= " AND n.fk_soc = s.rowid";
     if (is_numeric($notifcode)) {
         $sql .= " AND n.fk_action = " . $notifcode;
     } else {
         $sql .= " AND a.code = '" . $notifcode . "'";
     }
     // New usage
     $sql .= " AND s.rowid = " . $object->socid;
     $result = $this->db->query($sql);
     if ($result) {
         $num = $this->db->num_rows($result);
         if ($num > 0) {
             $i = 0;
             while ($i < $num && !$error) {
                 $obj = $this->db->fetch_object($result);
                 $sendto = dolGetFirstLastname($obj->firstname, $obj->lastname) . " <" . $obj->email . ">";
                 $notifcodedefid = $obj->adid;
                 if (dol_strlen($obj->email)) {
                     // Set output language
                     $outputlangs = $langs;
                     if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
                         $outputlangs = new Translate('', $conf);
                         $outputlangs->setDefaultLang($obj->default_lang);
                     }
                     switch ($notifcode) {
                         case 'BILL_VALIDATE':
                             $link = '/compta/facture.php?facid=' . $object->id;
                             $dir_output = $conf->facture->dir_output;
                             $object_type = 'facture';
                             $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref);
                             break;
                         case 'ORDER_VALIDATE':
                             $link = '/commande/card.php?id=' . $object->id;
                             $dir_output = $conf->commande->dir_output;
                             $object_type = 'order';
                             $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $newref);
                             break;
                         case 'PROPAL_VALIDATE':
                             $link = '/comm/propal.php?id=' . $object->id;
                             $dir_output = $conf->propal->dir_output;
                             $object_type = 'propal';
                             $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $newref);
                             break;
                         case 'FICHINTER_VALIDATE':
                             $link = '/fichinter/card.php?id=' . $object->id;
                             $dir_output = $conf->facture->dir_output;
                             $object_type = 'ficheinter';
                             $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $object->ref);
                             break;
                         case 'ORDER_SUPPLIER_VALIDATE':
                             $link = '/fourn/commande/card.php?id=' . $object->id;
                             $dir_output = $conf->fournisseur->dir_output . '/commande/';
                             $object_type = 'order_supplier';
                             $mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
                             $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $object->ref, $user->getFullName($langs));
                             $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                             break;
                         case 'ORDER_SUPPLIER_APPROVE':
                             $link = '/fourn/commande/card.php?id=' . $object->id;
                             $dir_output = $conf->fournisseur->dir_output . '/commande/';
                             $object_type = 'order_supplier';
                             $mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
                             $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($langs));
                             $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                             break;
                         case 'ORDER_SUPPLIER_REFUSE':
                             $link = '/fourn/commande/card.php?id=' . $object->id;
                             $dir_output = $conf->fournisseur->dir_output . '/commande/';
                             $object_type = 'order_supplier';
                             $mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
                             $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($langs));
                             $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                             break;
                         case 'SHIPPING_VALIDATE':
                             $dir_output = $conf->expedition->dir_output . '/sending/';
                             $object_type = 'order_supplier';
                             $mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated", $newref);
                             break;
                     }
                     $ref = dol_sanitizeFileName($newref);
                     $pdf_path = $dir_output . "/" . $ref . "/" . $ref . ".pdf";
                     if (!dol_is_file($pdf_path)) {
                         // We can't add PDF as it is not generated yet.
                         $filepdf = '';
                     } else {
                         $filepdf = $pdf_path;
                     }
                     $subject = '[' . $application . '] ' . $outputlangs->transnoentitiesnoconv("DolibarrNotification");
                     $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name) . "\n";
                     $message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name) . "\n";
                     $message .= "\n";
                     $message .= $mesg;
                     if ($link) {
                         $message = dol_concatdesc($message, $urlwithroot . $link);
                     }
                     $mailfile = new CMailFile($subject, $sendto, $replyto, $message, array($file), array($mimefile), array($filename[count($filename) - 1]), '', '', 0, -1);
                     if ($mailfile->sendfile()) {
                         $sql = "INSERT INTO " . MAIN_DB_PREFIX . "notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, objet_id, email)";
                         $sql .= " VALUES ('" . $this->db->idate(dol_now()) . "', " . $notifcodedefid . ", " . $object->socid . ", " . $obj->cid . ", '" . $obj->type . "', '" . $object_type . "', " . $object->id . ", '" . $this->db->escape($obj->email) . "')";
                         if (!$this->db->query($sql)) {
                             dol_print_error($this->db);
                         }
                     } else {
                         $error++;
                         $this->errors[] = $mailfile->error;
                     }
                 } else {
                     dol_syslog("No notification sent for " . $sendto . " because email is empty");
                 }
                 $i++;
             }
         } else {
             dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = " . $object->socid);
         }
     } else {
         $error++;
         $this->errors[] = $this->db->lasterror();
         return -1;
     }
     // Check notification using fixed email
     if (!$error) {
         foreach ($conf->global as $key => $val) {
             if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_' . $notifcode . '_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
                 continue;
             }
             $threshold = (double) $reg[1];
             if ($object->total_ht <= $threshold) {
                 dol_syslog("A notification is requested for notifcode = " . $notifcode . " but amount = " . $object->total_ht . " so lower than threshold = " . $threshold . ". We discard this notification");
                 continue;
             }
             $param = 'NOTIFICATION_FIXEDEMAIL_' . $notifcode . '_THRESHOLD_HIGHER_' . $reg[1];
             $sendto = $conf->global->{$param};
             $notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
             if ($notifcodedefid <= 0) {
                 dol_print_error($this->db, 'Failed to get id from code');
             }
             $object_type = '';
             $link = '';
             $num++;
             switch ($notifcode) {
                 case 'BILL_VALIDATE':
                     $link = '/compta/facture.php?facid=' . $object->id;
                     $dir_output = $conf->facture->dir_output;
                     $object_type = 'facture';
                     $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref);
                     break;
                 case 'ORDER_VALIDATE':
                     $link = '/commande/card.php?id=' . $object->id;
                     $dir_output = $conf->commande->dir_output;
                     $object_type = 'order';
                     $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $newref);
                     break;
                 case 'PROPAL_VALIDATE':
                     $link = '/comm/propal.php?id=' . $object->id;
                     $dir_output = $conf->propal->dir_output;
                     $object_type = 'propal';
                     $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $newref);
                     break;
                 case 'FICHINTER_VALIDATE':
                     $link = '/fichinter/card.php?id=' . $object->id;
                     $dir_output = $conf->facture->dir_output;
                     $object_type = 'ficheinter';
                     $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $newref);
                     break;
                 case 'ORDER_SUPPLIER_VALIDATE':
                     $link = '/fourn/commande/card.php?id=' . $object->id;
                     $dir_output = $conf->fournisseur->dir_output . '/commande/';
                     $object_type = 'order_supplier';
                     $mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
                     $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($langs));
                     $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                     break;
                 case 'ORDER_SUPPLIER_APPROVE':
                     $link = '/fourn/commande/card.php?id=' . $object->id;
                     $dir_output = $conf->fournisseur->dir_output . '/commande/';
                     $object_type = 'order_supplier';
                     $mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
                     $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($langs));
                     $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                     break;
                 case 'ORDER_SUPPLIER_APPROVE2':
                     $link = '/fourn/commande/card.php?id=' . $object->id;
                     $dir_output = $conf->fournisseur->dir_output . '/commande/';
                     $object_type = 'order_supplier';
                     $mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
                     $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($langs));
                     $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                     break;
                 case 'ORDER_SUPPLIER_REFUSE':
                     $link = '/fourn/commande/card.php?id=' . $object->id;
                     $dir_output = $conf->fournisseur->dir_output . '/commande/';
                     $object_type = 'order_supplier';
                     $mesg = $langs->transnoentitiesnoconv("Hello") . ",\n\n";
                     $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($langs));
                     $mesg .= "\n\n" . $langs->transnoentitiesnoconv("Sincerely") . ".\n\n";
                     break;
                 case 'SHIPPING_VALIDATE':
                     $dir_output = $conf->expedition->dir_output . '/sending/';
                     $object_type = 'order_supplier';
                     $mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated", $newref);
                     break;
             }
             $ref = dol_sanitizeFileName($newref);
             $pdf_path = $dir_output . "/" . $ref . "/" . $ref . ".pdf";
             if (!dol_is_file($pdf_path)) {
                 // We can't add PDF as it is not generated yet.
                 $filepdf = '';
             } else {
                 $filepdf = $pdf_path;
             }
             $subject = '[' . $application . '] ' . $langs->transnoentitiesnoconv("DolibarrNotification");
             $message = $langs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name) . "\n";
             $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name) . "\n";
             $message .= "\n";
             $message .= $mesg;
             if ($link) {
                 $message = dol_concatdesc($message, $urlwithroot . $link);
             }
             // Replace keyword __SUPERVISOREMAIL__
             if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) {
                 $newval = '';
                 if ($user->fk_user > 0) {
                     $supervisoruser = new User($this->db);
                     $supervisoruser->fetch($user->fk_user);
                     if ($supervisoruser->email) {
                         $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname) . ' <' . $supervisoruser->email . '>');
                     }
                 }
                 dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with " . $newval);
                 $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
                 $sendto = preg_replace('/^[\\s,]+/', '', $sendto);
                 // Clean start of string
                 $sendto = preg_replace('/[\\s,]+$/', '', $sendto);
                 // Clean end of string
             }
             if ($sendto) {
                 $mailfile = new CMailFile($subject, $sendto, $replyto, $message, array($file), array($mimefile), array($filename[count($filename) - 1]), '', '', 0, -1);
                 if ($mailfile->sendfile()) {
                     $sql = "INSERT INTO " . MAIN_DB_PREFIX . "notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, objet_id, email)";
                     $sql .= " VALUES ('" . $this->db->idate(dol_now()) . "', " . $notifcodedefid . ", " . $object->socid . ", null, 'email', '" . $object_type . "', " . $object->id . ", '" . $this->db->escape($conf->global->{$param}) . "')";
                     if (!$this->db->query($sql)) {
                         dol_print_error($this->db);
                     }
                 } else {
                     $error++;
                     $this->errors[] = $mailfile->error;
                 }
             }
         }
     }
     if (!$error) {
         return $num;
     } else {
         return -1 * $error;
     }
 }
Exemplo n.º 16
0
    $sql .= " AND u.fk_societe = " . $socid;
}
$sql .= $db->order("u.datec", "DESC");
$sql .= $db->plimit($max);
$resql = $db->query($sql);
if ($resql) {
    $num = $db->num_rows($resql);
    print '<table class="noborder" width="100%">';
    print '<tr class="liste_titre"><td colspan="5">' . $langs->trans("LastUsersCreated", min($num, $max)) . '</td></tr>';
    $var = true;
    $i = 0;
    while ($i < $num && $i < $max) {
        $obj = $db->fetch_object($resql);
        $var = !$var;
        print "<tr " . $bc[$var] . ">";
        print '<td><a href="' . DOL_URL_ROOT . '/user/card.php?id=' . $obj->rowid . '">' . img_object($langs->trans("ShowUser"), "user") . ' ' . dolGetFirstLastname($obj->firstname, $obj->lastname) . '</a>';
        if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) {
            print img_picto($langs->trans("SuperAdministrator"), 'redstar');
        } else {
            if ($obj->admin) {
                print img_picto($langs->trans("Administrator"), 'star');
            }
        }
        print "</td>";
        print '<td align="left">' . $obj->login . '</td>';
        print "<td>";
        if ($obj->fk_societe) {
            $companystatic->id = $obj->fk_societe;
            $companystatic->name = $obj->name;
            $companystatic->canvas = $obj->canvas;
            print $companystatic->getNomUrl(1);
function _fiche(&$PDOdb, $id)
{
    global $conf, $db, $langs, $user, $form;
    $object = new Categorie($db);
    $result = $object->fetch($id);
    $object->fetch_optionals($id, $extralabels);
    if ($result <= 0) {
        dol_print_error($db, $object->error);
        exit;
    }
    llxHeader("", "", $langs->trans("Categories"));
    $title = $langs->trans("CustomersCategoryShort");
    $head = categories_prepare_head($object, Categorie::TYPE_CUSTOMER);
    dol_fiche_head($head, 'commercial', $title, 0, 'category');
    print '<table class="border" width="100%">';
    print '<tr><td width="20%" class="notopnoleft">';
    $ways = $object->print_all_ways();
    print $langs->trans("Ref") . '</td><td>';
    print '<a href="' . DOL_URL_ROOT . '/categories/index.php?leftmenu=cat&type=' . $type . '">' . $langs->trans("Root") . '</a> >> ';
    foreach ($ways as $way) {
        print $way . "<br>\n";
    }
    print '</td></tr>';
    // Description
    print '<tr><td width="20%" class="notopnoleft">';
    print $langs->trans("Description") . '</td><td>';
    print dol_htmlentitiesbr($object->description);
    print '</td></tr>';
    print '<tr><td>' . $langs->trans("SalesRepresentatives") . '</td>';
    print '<td>';
    $TUser = TCommercialCategory::getUser($PDOdb, $object->id);
    if (!empty($TUser)) {
        foreach ($TUser as &$u) {
            echo $u->getNomUrl(1);
            if ($user->rights->societe->creer) {
                print '<a href="?id=' . $object->id . '&commid=' . $u->id . '&action=delete">';
                print img_delete();
                print '</a>';
            }
            print '<br />';
        }
    }
    print '</td></tr>';
    print '</table>';
    dol_fiche_end();
    if ($user->rights->societe->creer && $user->rights->societe->client->voir) {
        /*
         * Copier... Coller... Jobi... Joba...
         */
        $langs->load("users");
        $title = $langs->trans("ListOfUsers");
        $sql = "SELECT u.rowid, u.lastname, u.firstname, u.login";
        $sql .= " FROM " . MAIN_DB_PREFIX . "user as u LEFT JOIN " . MAIN_DB_PREFIX . "commercial_category cc ON (cc.fk_user = u .rowid AND cc.fk_category=" . $object->id . ")";
        $sql .= " WHERE u.entity IN (0," . $conf->entity . ")";
        if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) {
            $sql .= " AND u.statut<>0 ";
        }
        $sql .= " AND cc.rowid IS NULL ";
        $sql .= " ORDER BY u.lastname ASC ";
        //var_dump($sql);
        $resql = $db->query($sql);
        if ($resql) {
            $num = $db->num_rows($resql);
            $i = 0;
            print load_fiche_titre($title);
            // Lignes des titres
            print '<table class="noborder" width="100%">';
            print '<tr class="liste_titre">';
            print '<td>' . $langs->trans("Name") . '</td>';
            print '<td>' . $langs->trans("Login") . '</td>';
            print '<td>&nbsp;</td>';
            print "</tr>\n";
            $var = True;
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $var = !$var;
                print "<tr " . $bc[$var] . "><td>";
                print '<a href="' . DOL_URL_ROOT . '/user/card.php?id=' . $obj->rowid . '">';
                print img_object($langs->trans("ShowUser"), "user") . ' ';
                print dolGetFirstLastname($obj->firstname, $obj->lastname) . "\n";
                print '</a>';
                print '</td><td>' . $obj->login . '</td>';
                print '<td><a href="?id=' . $object->id . '&commid=' . $obj->rowid . '&action=add">' . $langs->trans("Add") . '</a></td>';
                print '</tr>' . "\n";
                $i++;
            }
            print "</table>";
            $db->free($resql);
        } else {
            dol_print_error($db);
        }
    }
    llxFooter();
}
         if (empty($obj->email)) {
             print "Warning: Sale representative " . $salerepresentative . " has no email. Notice disabled.\n";
         }
     }
     // Define line content
     $outputlangs = new Translate('', $conf);
     $outputlangs->setDefaultLang(empty($obj->lang) ? $langs->defaultlang : $obj->lang);
     // By default language of sale representative
     $outputlangs->load("bills");
     $outputlangs->load("main");
     if (dol_strlen($obj->email)) {
         $message .= $outputlangs->trans("Invoice") . " " . $obj->facnumber . " : " . price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) . " : " . $obj->name . "\n";
         dol_syslog("email_unpaid_invoices_to_representatives.php: " . $obj->email);
         $foundtoprocess++;
     }
     print "Unpaid invoice " . $obj->facnumber . ", price " . price2num($obj->total_ttc) . ", due date " . dol_print_date($db->jdate($obj->due_date), 'day') . " (linked to company " . $obj->name . ", sale representative " . dolGetFirstLastname($obj->firstname, $obj->lastname) . ", email " . $obj->email . ", lang " . $outputlangs->defaultlang . "): ";
     if (dol_strlen($obj->email)) {
         print "qualified.";
     } else {
         print "disqualified (no email).";
     }
     print "\n";
     unset($outputlangs);
     $total += $obj->total_ttc;
     $i++;
 }
 // Si il reste des envois en buffer
 if ($foundtoprocess) {
     if (dol_strlen($oldemail) && $oldemail != 'none') {
         envoi_mail($mode, $oldemail, $message, $total, $oldlang, $oldsalerepresentative);
     } else {
Exemplo n.º 19
0
$sql .= $db->plimit($conf->liste_limit, $offset);
$result = $db->query($sql);
if ($result) {
    $num = $db->num_rows($result);
    $i = 0;
    $paramlist = '';
    print_barre_liste($langs->trans("ListOfNotificationsDone"), $page, "index.php", $paramlist, $sortfield, $sortorder, '', $num);
    print '<table class="noborder" width="100%">';
    print '<tr class="liste_titre">';
    print_liste_field_titre($langs->trans("Company"), "index.php", "s.nom", "", "", 'valign="center"', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("Contact"), "index.php", "c.lastname", "", "", 'valign="center"', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("Action"), "index.php", "a.titre", "", "", 'valign="center"', $sortfield, $sortorder);
    print "</tr>\n";
    $var = True;
    while ($i < $num) {
        $obj = $db->fetch_object($result);
        $var = !$var;
        print "<tr " . $bc[$var] . ">";
        print "<td><a href=\"fiche.php?socid=" . $obj->socid . "\">" . $obj->nom . "</a></td>\n";
        print "<td>" . dolGetFirstLastname($obj->firstname, $obj->lastname) . "</td>\n";
        print "<td>" . $obj->titre . "</td>\n";
        print "</tr>\n";
        $i++;
    }
    print "</table>";
    $db->free();
} else {
    dol_print_error($db);
}
llxFooter();
$db->close();
Exemplo n.º 20
0
 print '<table class="public_border" width="100%">';
 print '<tr class="public_liste_titre">';
 print '<td><a href="' . $_SERVER["PHP_SELF"] . '?page=' . $page . '&sortorder=ASC&sortfield=firstname">' . dolGetFirstLastname($langs->trans("Firstname"), $langs->trans("Lastname")) . '</a></td>';
 print '<td><a href="' . $_SERVER["PHP_SELF"] . '?page=' . $page . '&sortorder=ASC&sortfield=societe">' . $langs->trans("Company") . '</a></td>' . "\n";
 //print_liste_field_titre($langs->trans("DateToBirth"), $_SERVER["PHP_SELF"],"birth",'',$param,$sortfield,$sortorder); // est-ce nécessaire ??
 print_liste_field_titre($langs->trans("EMail"), $_SERVER["PHP_SELF"], "email", '', $param, '', $sortfield, $sortorder, 'public_');
 print_liste_field_titre($langs->trans("Zip"), $_SERVER["PHP_SELF"], "zip", "", $param, '', $sortfield, $sortorder, 'public_');
 print_liste_field_titre($langs->trans("Town"), $_SERVER["PHP_SELF"], "town", "", $param, '', $sortfield, $sortorder, 'public_');
 print_liste_field_titre($langs->trans("Photo"), $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'public_');
 print "</tr>\n";
 $var = True;
 while ($i < $num && $i < $conf->liste_limit) {
     $objp = $db->fetch_object($result);
     $var = !$var;
     print "<tr " . $bc[$var] . ">";
     print '<td><a href="public_card.php?id=' . $objp->rowid . '">' . dolGetFirstLastname($objp->firstname, $objp->lastname) . '</a></td>' . "\n";
     print '<td>' . $objp->societe . '</td>' . "\n";
     print '<td>' . $objp->email . '</td>' . "\n";
     print '<td>' . $objp->zip . '</td>' . "\n";
     print '<td>' . $objp->town . '</td>' . "\n";
     if (isset($objp->photo) && $objp->photo != '') {
         print '<td>';
         print $form->showphoto('memberphoto', $objp, 64);
         print '</td>' . "\n";
     } else {
         print "<td>&nbsp;</td>\n";
     }
     print "</tr>";
     $i++;
 }
 print "</table>";
 /**
  *  Load an object from database
  *
  *  @param  int     $id     Id
  *  @param  string  $ref    Ref
  *  @return int             <0 if KO, >0 if OK
  */
 function fetch($id, $ref = '')
 {
     global $conf;
     $sql = "SELECT d.rowid, d.ref, d.note_public, d.note_private,";
     // DEFAULT
     $sql .= " d.detail_refuse, d.detail_cancel, d.fk_user_refuse, d.fk_user_cancel,";
     // ACTIONS
     $sql .= " d.date_refuse, d.date_cancel,";
     // ACTIONS
     $sql .= " d.total_ht, d.total_ttc, d.total_tva,";
     // TOTAUX (int)
     $sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve,";
     // DATES (datetime)
     $sql .= " d.fk_user_author, d.fk_user_modif, d.fk_user_validator,";
     $sql .= " d.fk_user_valid, d.fk_user_approve,";
     $sql .= " d.fk_statut as status, d.fk_c_paiement,";
     $sql .= " dp.libelle as libelle_paiement, dp.code as code_paiement";
     // INNER JOIN paiement
     $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element . " as d LEFT JOIN " . MAIN_DB_PREFIX . "c_paiement as dp ON d.fk_c_paiement = dp.id";
     if ($ref) {
         $sql .= " WHERE d.ref = '" . $this->db->escape($ref) . "'";
     } else {
         $sql .= " WHERE d.rowid = " . $id;
     }
     $sql .= $restrict;
     dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
     $resql = $this->db->query($sql);
     if ($resql) {
         $obj = $this->db->fetch_object($resql);
         if ($obj) {
             $this->id = $obj->rowid;
             $this->ref = $obj->ref;
             $this->total_ht = $obj->total_ht;
             $this->total_tva = $obj->total_tva;
             $this->total_ttc = $obj->total_ttc;
             $this->note_public = $obj->note_public;
             $this->note_private = $obj->note_private;
             $this->detail_refuse = $obj->detail_refuse;
             $this->detail_cancel = $obj->detail_cancel;
             $this->date_debut = $this->db->jdate($obj->date_debut);
             $this->date_fin = $this->db->jdate($obj->date_fin);
             $this->date_valid = $this->db->jdate($obj->date_valid);
             $this->date_approve = $this->db->jdate($obj->date_approve);
             $this->date_create = $this->db->jdate($obj->date_create);
             $this->date_modif = $this->db->jdate($obj->date_modif);
             $this->date_refuse = $this->db->jdate($obj->date_refuse);
             $this->date_cancel = $this->db->jdate($obj->date_cancel);
             $this->fk_user_author = $obj->fk_user_author;
             $this->fk_user_modif = $obj->fk_user_modif;
             $this->fk_user_validator = $obj->fk_user_validator;
             $this->fk_user_valid = $obj->fk_user_valid;
             $this->fk_user_refuse = $obj->fk_user_refuse;
             $this->fk_user_cancel = $obj->fk_user_cancel;
             $this->fk_user_approve = $obj->fk_user_approve;
             $user_author = new User($this->db);
             if ($this->fk_user_author > 0) {
                 $user_author->fetch($this->fk_user_author);
             }
             $this->user_author_infos = dolGetFirstLastname($user_author->firstname, $user_author->lastname);
             $user_approver = new User($this->db);
             if ($this->fk_user_validator > 0) {
                 $user_approver->fetch($this->fk_user_validator);
             }
             $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname);
             $this->fk_statut = $obj->status;
             $this->status = $obj->status;
             $this->fk_c_paiement = $obj->fk_c_paiement;
             $this->paid = $obj->paid;
             if ($this->fk_statut == 5 || $this->fk_statut == 6) {
                 $user_valid = new User($this->db);
                 if ($this->fk_user_valid > 0) {
                     $user_valid->fetch($this->fk_user_valid);
                 }
                 $this->user_valid_infos = dolGetFirstLastname($user_valid->firstname, $user_valid->lastname);
             }
             $this->libelle_statut = $obj->libelle_statut;
             $this->libelle_paiement = $obj->libelle_paiement;
             $this->code_statut = $obj->code_statut;
             $this->code_paiement = $obj->code_paiement;
             $this->lignes = array();
             // deprecated
             $this->lines = array();
             $result = $this->fetch_lines();
             return $result;
         } else {
             return 0;
         }
     } else {
         $this->error = $this->db->lasterror();
         return -1;
     }
 }
Exemplo n.º 22
0
 /**
  *  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');
         }
     }
 }
 /**
  *  Return select list for categories (to use in form search selectors)
  *
  *  @param	string	$selected     	Preselected value
  *  @param  string	$htmlname      	Name of combo list (example: 'search_sale')
  *  @param  User	$user           Object user
  *  @param	int		$showstatus		0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
  *  @return string					Html combo list code
  */
 function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0)
 {
     global $conf, $langs;
     $langs->load('users');
     // Select each sales and print them in a select input
     $moreforfilter = '<select class="flat" name="' . $htmlname . '">';
     $moreforfilter .= '<option value="">&nbsp;</option>';
     // Get list of users allowed to be viewed
     $sql_usr = "******";
     $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u";
     $sql_usr .= " WHERE u.entity IN (0," . $conf->entity . ")";
     if (empty($user->rights->user->user->lire)) {
         $sql_usr .= " AND u.rowid = " . $user->id;
     }
     if (!empty($user->societe_id)) {
         $sql_usr .= " AND u.fk_societe = " . $user->societe_id;
     }
     // Add existing sales representatives of thirdparty of external user
     if (empty($user->rights->user->user->lire) && $user->societe_id) {
         $sql_usr .= " UNION ";
         $sql_usr .= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut, u2.login";
         $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         $sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")";
         $sql_usr .= " AND u2.rowid = sc.fk_user AND sc.fk_soc=" . $user->societe_id;
     }
     $sql_usr .= " ORDER BY lastname ASC";
     //print $sql_usr;exit;
     $resql_usr = $this->db->query($sql_usr);
     if ($resql_usr) {
         while ($obj_usr = $this->db->fetch_object($resql_usr)) {
             $moreforfilter .= '<option value="' . $obj_usr->rowid . '"';
             if ($obj_usr->rowid == $selected) {
                 $moreforfilter .= ' selected="selected"';
             }
             $moreforfilter .= '>';
             $moreforfilter .= dolGetFirstLastname($obj_usr->firstname, $obj_usr->lastname);
             // Complete name with more info
             $moreinfo = 0;
             if (!empty($conf->global->MAIN_SHOW_LOGIN)) {
                 $moreforfilter .= ($moreinfo ? ' - ' : ' (') . $obj_usr->login;
                 $moreinfo++;
             }
             if ($showstatus >= 0) {
                 if ($obj_usr->statut == 1 && $showstatus == 1) {
                     $moreforfilter .= ($moreinfo ? ' - ' : ' (') . $langs->trans('Enabled');
                     $moreinfo++;
                 }
                 if ($obj_usr->statut == 0) {
                     $moreforfilter .= ($moreinfo ? ' - ' : ' (') . $langs->trans('Disabled');
                     $moreinfo++;
                 }
             }
             $moreforfilter .= $moreinfo ? ')' : '';
             $moreforfilter .= '</option>';
         }
         $this->db->free($resql_usr);
     } else {
         dol_print_error($this->db);
     }
     $moreforfilter .= '</select>';
     return $moreforfilter;
 }