Merge pull request #16 from Dolibarr/develop

pull from develop
This commit is contained in:
Tobias Sekan 2020-04-16 08:48:19 +02:00 committed by GitHub
commit 0c20b6b2d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 7455 additions and 7409 deletions

View File

@ -86,13 +86,14 @@ class Members extends DolibarrApi
* @param int $limit Limit for list
* @param int $page Page number
* @param string $typeid ID of the type of member
* @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma.
* Example: "(t.ref:like:'SO-%') and ((t.date_creation:<:'20160101') or (t.nature:is:NULL))"
* @return array Array of member objects
*
* @throws RestException
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '')
{
global $db, $conf;
@ -104,11 +105,19 @@ class Members extends DolibarrApi
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as t";
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_member as c";
}
$sql .= ' WHERE t.entity IN ('.getEntity('adherent').')';
if (!empty($typeid))
{
$sql .= ' AND t.fk_adherent_type='.$typeid;
}
// Select members of given category
if ($category > 0) {
$sql .= " AND c.fk_categorie = ".$db->escape($category);
$sql .= " AND c.fk_member = t.rowid ";
}
// Add sql filters
if ($sqlfilters)
{

View File

@ -32,7 +32,7 @@ $langs->loadLangs(array("admin", "ticket"));
// Access control
if (!$user->admin) {
accessforbidden();
accessforbidden();
}
// Parameters
@ -49,117 +49,117 @@ $error = 0;
*/
if ($action == 'updateMask') {
$maskconstticket = GETPOST('maskconstticket', 'alpha');
$maskticket = GETPOST('maskticket', 'alpha');
$maskconstticket = GETPOST('maskconstticket', 'alpha');
$maskticket = GETPOST('maskticket', 'alpha');
if ($maskconstticket) {
$res = dolibarr_set_const($db, $maskconstticket, $maskticket, 'chaine', 0, '', $conf->entity);
}
if ($maskconstticket) {
$res = dolibarr_set_const($db, $maskconstticket, $maskticket, 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
if (!$res > 0) {
$error++;
}
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'setmod') {
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'setvar') {
include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
$notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha');
if (!empty($notification_email)) {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
$notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha');
if (!empty($notification_email)) {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
// altairis : differentiate notification email FROM and TO
$notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha');
if (!empty($notification_email_to)) {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
// altairis : differentiate notification email FROM and TO
$notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha');
if (!empty($notification_email_to)) {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
$mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml');
if (!empty($mail_intro)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
$mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml');
if (!empty($mail_intro)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
$mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml');
if (!empty($mail_signature)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
$mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml');
if (!empty($mail_signature)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
}
if ($action == 'setvarother') {
$param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
$param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
$param_disable_email = GETPOST('TICKET_DISABLE_NOTIFICATION_MAILS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_DISABLE_NOTIFICATION_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
$param_disable_email = GETPOST('TICKET_DISABLE_NOTIFICATION_MAILS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_DISABLE_NOTIFICATION_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
$param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
$param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
$param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
$param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
}
$param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
$param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
$param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
$param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
}
@ -195,7 +195,7 @@ dol_fiche_end();
* Projects Numbering model
*/
print load_fiche_titre($langs->trans("TicketNumberingModules"));
print load_fiche_titre($langs->trans("TicketNumberingModules"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
@ -210,82 +210,82 @@ print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/ticket");
$dir = dol_buildpath($reldir."core/modules/ticket");
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) {
$file = $reg[1];
$classname = substr($file, 4);
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) {
$file = $reg[1];
$classname = substr($file, 4);
include_once $dir.'/'.$file.'.php';
include_once $dir.'/'.$file.'.php';
$module = new $file;
$module = new $file;
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
continue;
}
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) {
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info();
print '</td>';
if ($module->isEnabled()) {
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info();
print '</td>';
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);
} else {
print $tmp;
}
// Show example of numbering model
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) {
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n";
print '</td>'."\n";
print '<td class="center">';
if ($conf->global->TICKET_ADDON == 'mod_'.$classname) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
}
print '</td>';
print '<td class="center">';
if ($conf->global->TICKET_ADDON == 'mod_'.$classname) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
}
print '</td>';
$ticket = new Ticket($db);
$ticket->initAsSpecimen();
$ticket = new Ticket($db);
$ticket->initAsSpecimen();
// Info
$htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval = $module->getNextValue($mysoc, $ticket);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
// Info
$htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval = $module->getNextValue($mysoc, $ticket);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
print '</tr>';
}
}
}
closedir($handle);
}
}
print '</tr>';
}
}
}
closedir($handle);
}
}
}
print '</table>';
@ -293,12 +293,12 @@ print '</div>';
print '<br>';
if (!$conf->use_javascript_ajax) {
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvarother">';
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvarother">';
}
print load_fiche_titre($langs->trans("TicketParams"));
print load_fiche_titre($langs->trans("Other"), '', '');
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
@ -307,86 +307,14 @@ print '<td></td>';
print '<td></td>';
print "</tr>\n";
// Activate email notifications
/*
print '<tr class="pair"><td>' . $langs->trans("TicketsDisableEmail") . '</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_DISABLE_ALL_MAILS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_DISABLE_ALL_MAILS", $arrval, $conf->global->TICKET_DISABLE_ALL_MAILS);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help');
print '</td>';
print '</tr>';
// Activate log by email
print '<tr class="pair"><td>' . $langs->trans("TicketsLogEnableEmail") . '</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsLogEnableEmailHelp"), 1, 'help');
print '</td>';
print '</tr>';
*/
// Also send to main email address
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress").'</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help');
print '</td>';
print '</tr>';
}
// Limiter la vue des tickets à ceux assignés à l'utilisateur
/*
print '<tr class="pair"><td>' . $langs->trans("TicketsLimitViewAssignedOnly") . '</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_LIMIT_VIEW_ASSIGNED_ONLY');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_LIMIT_VIEW_ASSIGNED_ONLY", $arrval, $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsLimitViewAssignedOnlyHelp"), 1, 'help');
print '</td>';
print '</tr>';
*/
/*if (!$conf->use_javascript_ajax) {
print '<tr class="impair"><td colspan="3" align="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '"></td>';
print '</tr>';
}*/
// Auto assign ticket at user who created it
print '<tr class="oddeven"><td>'.$langs->trans("TicketsAutoAssignTicket").'</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE);
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE);
}
print '</td>';
print '<td class="center">';
@ -397,11 +325,11 @@ print '</tr>';
print '</table><br>';
if (!$conf->use_javascript_ajax) {
print '</form>';
print '</form>';
}
// Admin var of module
print load_fiche_titre($langs->trans("Notification"));
print load_fiche_titre($langs->trans("Notification"), '', '');
print '<table class="noborder centpercent">';
@ -414,27 +342,11 @@ print '<td colspan="3">'.$langs->trans("Email").'</td>';
print "</tr>\n";
if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
print '<tr>';
print '<td colspan="3"><div class="info">'.$langs->trans("TicketCkEditorEmailNotActivated").'</div></td>';
print "</tr>\n";
print '<tr>';
print '<td colspan="3"><div class="info">'.$langs->trans("TicketCkEditorEmailNotActivated").'</div></td>';
print "</tr>\n";
}
// Activate log by email
/*print '<tr class="pair"><td>' . $langs->trans("TicketsLogEnableEmail") . '</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsLogEnableEmailHelp"), 1, 'help');
print '</td>';
print '</tr>';
*/
// @todo Use module notification instead...
// Email d'envoi des notifications
@ -446,18 +358,36 @@ print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"),
print '</td>';
print '</tr>';
// Email de réception des notifications
print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationTo").'</td>';
// Email for notification of TICKET_CREATE
print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationTo").' ('.$langs->trans("Creation").')</td>';
print '<td class="left">';
print '<input type="text" name="TICKET_NOTIFICATION_EMAIL_TO" value="'.(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? $conf->global->TICKET_NOTIFICATION_EMAIL_TO : $conf->global->TICKET_NOTIFICATION_EMAIL_FROM).'" size="20" ></td>';
print '<input type="text" name="TICKET_NOTIFICATION_EMAIL_TO" value="'.(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? $conf->global->TICKET_NOTIFICATION_EMAIL_TO : '').'"></td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
print '</td>';
print '</tr>';
// Also send to TICKET_NOTIFICATION_EMAIL_TO for responses (not only creation)
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress").'</td>';
print '<td class="left">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
}
print '</td>';
print '<td class="center">';
print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help');
print '</td>';
print '</tr>';
}
// Texte d'introduction
$mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText');
print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailIntroLabelAdmin").'</label>';
print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailIntroLabelAdmin").' ('.$langs->trans("Responses").')';
print '</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);

View File

@ -57,12 +57,13 @@ class BankAccounts extends DolibarrApi
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"
* @return array List of account objects
*
* @throws RestException
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $category = 0, $sqlfilters = '')
{
$list = array();
@ -71,7 +72,14 @@ class BankAccounts extends DolibarrApi
}
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t";
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_account as c";
}
$sql .= ' WHERE t.entity IN ('.getEntity('bank_account').')';
// Select accounts of given category
if ($category > 0) {
$sql .= " AND c.fk_categorie = ".$db->escape($category)." AND c.fk_account = t.rowid ";
}
// Add sql filters
if ($sqlfilters)
{

View File

@ -75,6 +75,8 @@ if ($action == 'add' && !empty($permissiontoadd))
$value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int');
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
} elseif ($object->fields[$key]['type'] == 'boolean') {
$value = (GETPOST($key) == 'on' ? 1 : 0);
} else {
$value = GETPOST($key, 'alphanohtml');
}
@ -156,6 +158,8 @@ if ($action == 'update' && !empty($permissiontoadd))
}
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
} elseif ($object->fields[$key]['type'] == 'boolean') {
$value = (GETPOST($key) == 'on' ? 1 : 0);
} else {
$value = GETPOST($key, 'alpha');
}

View File

@ -6,6 +6,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -386,6 +387,12 @@ abstract class CommonDocGenerator
$sumcreditnote = $object->getSumCreditNotesUsed();
$already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote;
$remain_to_pay = $sumpayed - $sumdeposit - $sumcreditnote;
if ($object->fk_account > 0) {
require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
$bank_account = new Account($this->db);
$bank_account->fetch($object->fk_account);
}
}
$date = ($object->element == 'contrat' ? $object->date_contrat : $object->date);
@ -414,6 +421,9 @@ abstract class CommonDocGenerator
$array_key.'_payment_term_code'=>$object->cond_reglement_code,
$array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)),
$array_key.'_bank_iban'=>$bank_account->iban,
$array_key.'_bank_bic'=>$bank_account->bic,
$array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs),
$array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)),
$array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs),

View File

@ -30,9 +30,9 @@
class FormProjets
{
/**
* @var DoliDB Database handler.
*/
public $db;
* @var DoliDB Database handler.
*/
public $db;
/**
* @var string Error code (or message)
@ -50,7 +50,7 @@ class FormProjets
$this->db = $db;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Output a combo list with projects qualified for a third party / user
*
@ -71,9 +71,9 @@ class FormProjets
* @param int $htmlid Html id to use instead of htmlname
* @return string Return html content
*/
public function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '')
{
// phpcs:enable
public function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '')
{
// phpcs:enable
global $langs, $conf, $form;
$out = '';
@ -90,13 +90,13 @@ class FormProjets
$selected_input_value = $project->ref;
}
$urloption = 'socid='.$socid.'&htmlname='.$htmlname.'&discardclosed='.$discard_closed;
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array(
// 'update' => array(
// 'projectid' => 'id'
// )
));
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array(
// 'update' => array(
// 'projectid' => 'id'
// )
));
$out .= '<input type="text" class="minwidth200'.($morecss ? ' '.$morecss : '').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
$out .= '<input type="text" class="minwidth200'.($morecss ? ' '.$morecss : '').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
}
else
{
@ -113,13 +113,13 @@ class FormProjets
if (empty($nooutput))
{
print $out;
return '';
print $out;
return '';
}
else return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Returns an array with projects qualified for a third party
*
@ -130,8 +130,8 @@ class FormProjets
* @param int $option_only Return only html options lines without the select tag
* @param int $show_empty Add an empty line
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
* @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled
* @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled
* @param int $mode 0 for HTML mode and 1 for array return (to be used by json_encode for example)
* @param string $filterkey Key to filter
* @param int $nooutput No print output. Return it only.
@ -140,9 +140,9 @@ class FormProjets
* @param string $morecss More CSS
* @return int Nb of project if OK, <0 if KO
*/
public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500')
{
// phpcs:enable
public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500')
{
// phpcs:enable
global $user, $conf, $langs;
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@ -170,11 +170,11 @@ class FormProjets
if ($socid == 0) $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
if ($socid > 0)
{
if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
{
$sql .= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)";
}
if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
{
$sql .= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)";
}
}
if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey);
$sql .= " ORDER BY p.ref ASC";
@ -186,9 +186,9 @@ class FormProjets
if (!empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
$out .= $comboenhancement;
$morecss .= ' minwidth100';
$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
$out .= $comboenhancement;
$morecss .= ' minwidth100';
}
if (empty($option_only)) {
@ -223,8 +223,8 @@ class FormProjets
$labeltoshow .= ', '.dol_trunc($obj->title, $maxlength);
if ($obj->name)
{
$labeltoshow .= ' - '.$obj->name;
if ($obj->name_alias) $labeltoshow .= ' ('.$obj->name_alias.')';
$labeltoshow .= ' - '.$obj->name;
if ($obj->name_alias) $labeltoshow .= ' ('.$obj->name_alias.')';
}
$disabled = 0;
@ -287,8 +287,8 @@ class FormProjets
if (empty($option_only)) $out .= '</select>';
if (empty($nooutput))
{
print $out;
return '';
print $out;
return '';
}
else return $out;
} else {
@ -312,15 +312,15 @@ class FormProjets
* @param int $option_only Return only html options lines without the select tag
* @param string $show_empty Add an empty line ('1' or string to show for empty line)
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
* @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled
* @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled
* @param string $morecss More css added to the select component
* @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids.
* @param string $showproject 'all' = Show project info, ''=Hide project info
* @param User $usertofilter User object to use for filtering
* @return int Nbr of project if OK, <0 if KO
* @return int Nbr of tasks if OK, <0 if KO
*/
public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null)
public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null)
{
global $user, $conf, $langs;
@ -365,9 +365,9 @@ class FormProjets
if (!empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
$out .= $comboenhancement;
$morecss = 'minwidth200imp maxwidth500';
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
$out .= $comboenhancement;
$morecss = 'minwidth200imp maxwidth500';
}
if (empty($option_only)) {
@ -481,7 +481,7 @@ class FormProjets
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Build a HTML select list of element of same thirdparty to suggest to link them to project
*
@ -494,7 +494,7 @@ class FormProjets
*/
public function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet")
{
// phpcs:enable
// phpcs:enable
global $conf, $langs;
if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done)
@ -518,7 +518,7 @@ class FormProjets
break;
case "commande_fourn":
case "commande_fournisseur":
$sql = "SELECT t.rowid, t.ref, t.ref_supplier";
$sql = "SELECT t.rowid, t.ref, t.ref_supplier";
break;
case "facture_rec":
$sql = "SELECT t.rowid, t.titre as ref";
@ -535,10 +535,10 @@ class FormProjets
break;*/
return '';
case "commande":
case "contrat":
case "contrat":
case "fichinter":
$sql = "SELECT t.rowid, t.ref";
break;
$sql = "SELECT t.rowid, t.ref";
break;
case 'stock_mouvement':
$sql = 'SELECT t.rowid, t.label as ref';
$projectkey = 'fk_origin';
@ -560,8 +560,8 @@ class FormProjets
$sql .= " WHERE ".$projectkey." is null";
if (!empty($socid) && $linkedtothirdparty)
{
if (is_numeric($socid)) $sql .= " AND t.fk_soc=".$socid;
else $sql .= " AND t.fk_soc IN (".$socid.")";
if (is_numeric($socid)) $sql .= " AND t.fk_soc=".$socid;
else $sql .= " AND t.fk_soc IN (".$socid.")";
}
if (!in_array($table_element, array('expensereport_det', 'stock_mouvement'))) $sql .= ' AND t.entity IN ('.getEntity('project').')';
if ($linkedtothirdparty) $sql .= " AND s.rowid = t.fk_soc";
@ -640,15 +640,15 @@ class FormProjets
{
$sellist = '<select class="flat oppstatus'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
if ($showempty) {
// Without &nbsp, strange move of screen when switching value
$sellist .= '<option value="-1">&nbsp;</option>';
}
// Without &nbsp, strange move of screen when switching value
$sellist .= '<option value="-1">&nbsp;</option>';
}
if ($showallnone) {
$sellist .= '<option value="all"'.($preselected == 'all' ? ' selected="selected"' : '').'>-- '.$langs->trans("OnlyOpportunitiesShort").' --</option>';
$sellist .= '<option value="openedopp"'.($preselected == 'openedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("OpenedOpportunitiesShort").' --</option>';
$sellist .= '<option value="notopenedopp"'.($preselected == 'notopenedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotOpenedOpportunitiesShort").' --</option>';
$sellist .= '<option value="none"'.($preselected == 'none' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotAnOpportunityShort").' --</option>';
}
$sellist .= '<option value="all"'.($preselected == 'all' ? ' selected="selected"' : '').'>-- '.$langs->trans("OnlyOpportunitiesShort").' --</option>';
$sellist .= '<option value="openedopp"'.($preselected == 'openedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("OpenedOpportunitiesShort").' --</option>';
$sellist .= '<option value="notopenedopp"'.($preselected == 'notopenedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotOpenedOpportunitiesShort").' --</option>';
$sellist .= '<option value="none"'.($preselected == 'none' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotAnOpportunityShort").' --</option>';
}
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);

File diff suppressed because it is too large Load Diff

View File

@ -23,8 +23,8 @@
*/
// Define size of logo small and mini
$maxwidthsmall = 270; $maxheightsmall = 150;
$maxwidthmini = 128; $maxheightmini = 72;
$maxwidthsmall = 350; $maxheightsmall = 200; // Near 16/9eme
$maxwidthmini = 128; $maxheightmini = 72; // 16/9eme
$quality = 80;

View File

@ -34,83 +34,83 @@
*/
function build_calfile($format, $title, $desc, $events_array, $outputfile)
{
global $conf, $langs;
global $conf, $langs;
dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
if (empty($outputfile))
{
// -1 = error
return -1;
}
if (empty($outputfile))
{
// -1 = error
return -1;
}
// Note: A cal file is an UTF8 encoded file
$calfileh = fopen($outputfile, "w");
// Note: A cal file is an UTF8 encoded file
$calfileh = fopen($outputfile, "w");
if ($calfileh)
{
include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
if ($calfileh)
{
include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
$now = dol_now();
$encoding = "";
$now = dol_now();
$encoding = "";
if ($format === "vcal")
{
$encoding = "ENCODING=QUOTED-PRINTABLE:";
}
if ($format === "vcal")
{
$encoding = "ENCODING=QUOTED-PRINTABLE:";
}
// Print header
fwrite($calfileh, "BEGIN:VCALENDAR\n");
// Print header
fwrite($calfileh, "BEGIN:VCALENDAR\n");
// version is always "2.0"
fwrite($calfileh, "VERSION:2.0\n");
// version is always "2.0"
fwrite($calfileh, "VERSION:2.0\n");
fwrite($calfileh, "METHOD:PUBLISH\n");
fwrite($calfileh, "PRODID:-//DOLIBARR ".DOL_VERSION."\n");
fwrite($calfileh, "CALSCALE:GREGORIAN\n");
fwrite($calfileh, "X-WR-CALNAME:".$encoding.format_cal($format, $title)."\n");
fwrite($calfileh, "X-WR-CALDESC:".$encoding.format_cal($format, $desc)."\n");
//fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
fwrite($calfileh, "METHOD:PUBLISH\n");
fwrite($calfileh, "PRODID:-//DOLIBARR ".DOL_VERSION."\n");
fwrite($calfileh, "CALSCALE:GREGORIAN\n");
fwrite($calfileh, "X-WR-CALNAME:".$encoding.format_cal($format, $title)."\n");
fwrite($calfileh, "X-WR-CALDESC:".$encoding.format_cal($format, $desc)."\n");
//fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60)
{
$hh = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "hour");
$mm = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "min");
$ss = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "sec");
if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60)
{
$hh = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "hour");
$mm = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "min");
$ss = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "sec");
fwrite($calfileh, "X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
}
fwrite($calfileh, "X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
}
foreach ($events_array as $key => $event)
{
// See http://fr.wikipedia.org/wiki/ICalendar for format
// See http://www.ietf.org/rfc/rfc2445.txt for RFC
foreach ($events_array as $key => $event)
{
// See http://fr.wikipedia.org/wiki/ICalendar for format
// See http://www.ietf.org/rfc/rfc2445.txt for RFC
// TODO: avoid use extra event array, use objects direct thahtwas created before
// TODO: avoid use extra event array, use objects direct thahtwas created before
$uid = $event["uid"];
$type = $event["type"];
$startdate = $event["startdate"];
$duration = $event["duration"];
$enddate = $event["enddate"];
$summary = $event["summary"];
$category = $event["category"];
$priority = $event["priority"];
$fulldayevent = $event["fulldayevent"];
$location = $event["location"];
$email = $event["email"];
$url = $event["url"];
$transparency = $event["transparency"];
$description = dol_string_nohtmltag(preg_replace("/<br[\s\/]?>/i", "\n", $event["desc"]), 0);
$created = $event["created"];
$modified = $event["modified"];
$assignedUsers = $event["assignedUsers"];
$uid = $event["uid"];
$type = $event["type"];
$startdate = $event["startdate"];
$duration = $event["duration"];
$enddate = $event["enddate"];
$summary = $event["summary"];
$category = $event["category"];
$priority = $event["priority"];
$fulldayevent = $event["fulldayevent"];
$location = $event["location"];
$email = $event["email"];
$url = $event["url"];
$transparency = $event["transparency"];
$description = dol_string_nohtmltag(preg_replace("/<br[\s\/]?>/i", "\n", $event["desc"]), 0);
$created = $event["created"];
$modified = $event["modified"];
$assignedUsers = $event["assignedUsers"];
// Format
$summary = format_cal($format, $summary);
$description = format_cal($format, $description);
$category = format_cal($format, $category);
$location = format_cal($format, $location);
// Format
$summary = format_cal($format, $summary);
$description = format_cal($format, $description);
$category = format_cal($format, $category);
$location = format_cal($format, $location);
// Output the vCard/iCal VEVENT object
/*
@ -147,180 +147,180 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
END:VEVENT
*/
if ($type === "event")
{
fwrite($calfileh, "BEGIN:VEVENT\n");
fwrite($calfileh, "UID:".$uid."\n");
if ($type === "event")
{
fwrite($calfileh, "BEGIN:VEVENT\n");
fwrite($calfileh, "UID:".$uid."\n");
if (!empty($email))
{
fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
}
if (!empty($email))
{
fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
}
if (!empty($url))
{
fwrite($calfileh, "URL:".$url."\n");
}
if (!empty($url))
{
fwrite($calfileh, "URL:".$url."\n");
}
if (is_array($assignedUsers))
{
foreach ($assignedUsers as $assignedUser)
{
if ($assignedUser->email === $email)
{
continue;
}
if (is_array($assignedUsers))
{
foreach ($assignedUsers as $assignedUser)
{
if ($assignedUser->email === $email)
{
continue;
}
fwrite($calfileh, "ATTENDEE;RSVP=TRUE:mailto:".$assignedUser->email."\n");
}
}
fwrite($calfileh, "ATTENDEE;RSVP=TRUE:mailto:".$assignedUser->email."\n");
}
}
if ($created)
{
fwrite($calfileh, "CREATED:".dol_print_date($created, "dayhourxcard", true)."\n");
}
if ($created)
{
fwrite($calfileh, "CREATED:".dol_print_date($created, "dayhourxcard", true)."\n");
}
if ($modified)
{
fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, "dayhourxcard", true)."\n");
}
if ($modified)
{
fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, "dayhourxcard", true)."\n");
}
fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
if (!empty($location))
{
fwrite($calfileh, "LOCATION:".$encoding.$location."\n");
}
if (!empty($location))
{
fwrite($calfileh, "LOCATION:".$encoding.$location."\n");
}
if ($fulldayevent)
{
fwrite($calfileh, "X-FUNAMBOL-ALLDAY:1\n");
}
if ($fulldayevent)
{
fwrite($calfileh, "X-FUNAMBOL-ALLDAY:1\n");
}
// see https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcical/0f262da6-c5fd-459e-9f18-145eba86b5d2
if ($fulldayevent)
{
fwrite($calfileh, "X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\n");
}
// see https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcical/0f262da6-c5fd-459e-9f18-145eba86b5d2
if ($fulldayevent)
{
fwrite($calfileh, "X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\n");
}
// Date must be GMT dates
// Current date
fwrite($calfileh, "DTSTAMP:".dol_print_date($now, "dayhourxcard", true)."\n");
// Date must be GMT dates
// Current date
fwrite($calfileh, "DTSTAMP:".dol_print_date($now, "dayhourxcard", true)."\n");
// Start date
$prefix = "";
$startdatef = dol_print_date($startdate, "dayhourxcard", true);
// Start date
$prefix = "";
$startdatef = dol_print_date($startdate, "dayhourxcard", true);
if ($fulldayevent)
{
// Local time
$prefix = ";VALUE=DATE";
$startdatef = dol_print_date($startdate, "dayxcard", false);
}
if ($fulldayevent)
{
// Local time
$prefix = ";VALUE=DATE";
$startdatef = dol_print_date($startdate, "dayxcard", false);
}
fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n");
fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n");
// End date
if ($fulldayevent)
{
if (empty($enddate))
{
$enddate = dol_time_plus_duree($startdate, 1, "d");
}
}
else
{
if (empty($enddate))
{
$enddate = $startdate + $duration;
}
}
// End date
if ($fulldayevent)
{
if (empty($enddate))
{
$enddate = dol_time_plus_duree($startdate, 1, "d");
}
}
else
{
if (empty($enddate))
{
$enddate = $startdate + $duration;
}
}
$prefix = "";
$enddatef = dol_print_date($enddate, "dayhourxcard", true);
$prefix = "";
$enddatef = dol_print_date($enddate, "dayhourxcard", true);
if ($fulldayevent)
{
$prefix = ";VALUE=DATE";
$enddatef = dol_print_date($enddate + 1, "dayxcard", false);
if ($fulldayevent)
{
$prefix = ";VALUE=DATE";
$enddatef = dol_print_date($enddate + 1, "dayxcard", false);
// Local time
//$enddatef .= dol_print_date($enddate+1,"dayhourxcard",false);
}
// Local time
//$enddatef .= dol_print_date($enddate+1,"dayhourxcard",false);
}
fwrite($calfileh, "DTEND".$prefix.":".$enddatef."\n");
fwrite($calfileh, "STATUS:CONFIRMED"."\n");
fwrite($calfileh, "DTEND".$prefix.":".$enddatef."\n");
fwrite($calfileh, "STATUS:CONFIRMED"."\n");
if (!empty($transparency))
{
fwrite($calfileh, "TRANSP:".$transparency."\n");
}
if (!empty($transparency))
{
fwrite($calfileh, "TRANSP:".$transparency."\n");
}
if (!empty($category))
{
fwrite($calfileh, "CATEGORIES:".$encoding.$category."\n");
}
if (!empty($category))
{
fwrite($calfileh, "CATEGORIES:".$encoding.$category."\n");
}
fwrite($calfileh, "END:VEVENT\n");
}
fwrite($calfileh, "END:VEVENT\n");
}
// Output the vCard/iCal VJOURNAL object
if ($type === "journal")
{
fwrite($calfileh, "BEGIN:VJOURNAL\n");
fwrite($calfileh, "UID:".$uid."\n");
// Output the vCard/iCal VJOURNAL object
if ($type === "journal")
{
fwrite($calfileh, "BEGIN:VJOURNAL\n");
fwrite($calfileh, "UID:".$uid."\n");
if (!empty($email))
{
fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
}
if (!empty($email))
{
fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
}
if (!empty($url))
{
fwrite($calfileh, "URL:".$url."\n");
}
if (!empty($url))
{
fwrite($calfileh, "URL:".$url."\n");
}
if ($created)
{
fwrite($calfileh, "CREATED:".dol_print_date($created, "dayhourxcard", true)."\n");
}
if ($created)
{
fwrite($calfileh, "CREATED:".dol_print_date($created, "dayhourxcard", true)."\n");
}
if ($modified)
{
fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, "dayhourxcard", true)."\n");
}
if ($modified)
{
fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, "dayhourxcard", true)."\n");
}
fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
fwrite($calfileh, "STATUS:CONFIRMED"."\n");
fwrite($calfileh, "CATEGORIES:".$category."\n");
fwrite($calfileh, "LOCATION:".$location."\n");
fwrite($calfileh, "TRANSP:OPAQUE\n");
fwrite($calfileh, "CLASS:CONFIDENTIAL\n");
fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, "dayhourxcard", true)."\n");
fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
fwrite($calfileh, "STATUS:CONFIRMED"."\n");
fwrite($calfileh, "CATEGORIES:".$category."\n");
fwrite($calfileh, "LOCATION:".$location."\n");
fwrite($calfileh, "TRANSP:OPAQUE\n");
fwrite($calfileh, "CLASS:CONFIDENTIAL\n");
fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, "dayhourxcard", true)."\n");
fwrite($calfileh, "END:VJOURNAL\n");
}
}
fwrite($calfileh, "END:VJOURNAL\n");
}
}
// Footer
fwrite($calfileh, "END:VCALENDAR");
// Footer
fwrite($calfileh, "END:VCALENDAR");
fclose($calfileh);
fclose($calfileh);
if (!empty($conf->global->MAIN_UMASK))
{
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
}
else
{
dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
return -2;
}
if (!empty($conf->global->MAIN_UMASK))
{
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
}
else
{
dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
return -2;
}
}
/**
@ -333,38 +333,38 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
* @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category") or Array of WebsitePage
* @param string $outputfile Output file
* @param string $filter (optional) Filter
* @param string $url Url
* @param string $url Url (If empty, forge URL for agenda RSS export)
* @return int < 0 if ko, Nb of events in file if ok
*/
function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '')
{
global $user, $conf, $langs;
global $dolibarr_main_url_root;
global $user, $conf, $langs;
global $dolibarr_main_url_root;
dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
if (empty($outputfile))
{
// -1 = error
return -1;
}
if (empty($outputfile))
{
// -1 = error
return -1;
}
$fichier = fopen($outputfile, "w");
$fichier = fopen($outputfile, "w");
if ($fichier)
{
$date = date("r");
if ($fichier)
{
$date = date("r");
// Print header
fwrite($fichier, '<?xml version="1.0" encoding="'.$langs->charset_output.'"?>');
fwrite($fichier, "\n");
// Print header
fwrite($fichier, '<?xml version="1.0" encoding="'.$langs->charset_output.'"?>');
fwrite($fichier, "\n");
fwrite($fichier, '<rss version="2.0">');
fwrite($fichier, "\n");
fwrite($fichier, '<rss version="2.0">');
fwrite($fichier, "\n");
fwrite($fichier, "<channel>\n<title>".$title."</title>\n");
fwrite($fichier, "<channel>\n<title>".$title."</title>\n");
/*
/*
fwrite($fichier, "<description><![CDATA[".$desc.".]]></description>"."\n".
// "<language>fr</language>"."\n".
"<copyright>Dolibarr</copyright>"."\n".
@ -372,90 +372,91 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
"<generator>Dolibarr</generator>"."\n");
*/
if (empty($url)) {
// 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
if (empty($url)) {
// 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."/public/agenda/agendaexport.php?format=rss&exportkey=".urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
}
$url = $urlwithroot."/public/agenda/agendaexport.php?format=rss&exportkey=".urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
}
fwrite($fichier, "<link><![CDATA[".$url."]]></link>"."\n");
fwrite($fichier, "<link><![CDATA[".$url."]]></link>"."\n");
foreach ($events_array as $key => $event)
{
$eventqualified = true;
foreach ($events_array as $key => $event)
{
$eventqualified = true;
if ($filter)
{
// TODO Add a filter
if ($filter)
{
// TODO Add a filter
$eventqualified = false;
}
$eventqualified = false;
}
if ($eventqualified)
{
if (is_object($event) && get_class($event) == 'WebsitePage') {
// Convert object into an array
$tmpevent = array();
$tmpevent['uid'] = $event->id;
$tmpevent['startdate'] = $event->date_creation;
$tmpevent['summary'] = $event->title;
$tmpevent['url'] = $event->urlpage.'.php';
$tmpevent['author'] = $event->author_alias ? $event->author_alias : 'unknown';
//$tmpevent['category'] = '';
if ($eventqualified)
{
if (is_object($event) && get_class($event) == 'WebsitePage') {
// Convert object into an array
$tmpevent = array();
$tmpevent['uid'] = $event->id;
$tmpevent['startdate'] = $event->date_creation;
$tmpevent['summary'] = $event->title;
$tmpevent['url'] = $event->fullpageurl ? $event->fullpageurl : $event->pageurl.'.php';
$tmpevent['author'] = $event->author_alias ? $event->author_alias : 'unknown';
//$tmpevent['category'] = '';
$tmpevent['desc'] = $event->description;
$event = $tmpevent;
}
$event = $tmpevent;
}
$uid = $event["uid"];
$startdate = $event["startdate"];
$summary = $event["summary"];
$url = $event["url"];
$author = $event["author"];
$category = $event["category"];
$uid = $event["uid"];
$startdate = $event["startdate"];
$summary = $event["summary"];
$url = $event["url"];
$author = $event["author"];
$category = $event["category"];
/* No place inside a RSS
/* No place inside a RSS
$priority = $event["priority"];
$fulldayevent = $event["fulldayevent"];
$location = $event["location"];
$email = $event["email"];
*/
$description = dol_string_nohtmltag(preg_replace("/<br[\s\/]?>/i", "\n", $event["desc"]), 0);
$description = dol_string_nohtmltag(preg_replace("/<br[\s\/]?>/i", "\n", $event["desc"]), 0);
fwrite($fichier, "<item>\n");
fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n");
fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
fwrite($fichier, "<description><![CDATA[");
fwrite($fichier, "<item>\n");
fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n");
fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
fwrite($fichier, "<description><![CDATA[");
if ($description)
fwrite($fichier, $description);
// else
// fwrite($fichier, "NoDesc");
if ($description)
fwrite($fichier, $description);
// else
// fwrite($fichier, "NoDesc");
fwrite($fichier, "]]></description>\n");
fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n");
fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
fwrite($fichier, "</item>\n");
}
}
fwrite($fichier, "]]></description>\n");
fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n");
fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
fwrite($fichier, "</item>\n");
}
}
fwrite($fichier, "</channel>");
fwrite($fichier, "\n");
fwrite($fichier, "</rss>");
fwrite($fichier, "</channel>");
fwrite($fichier, "\n");
fwrite($fichier, "</rss>");
fclose($fichier);
fclose($fichier);
if (!empty($conf->global->MAIN_UMASK))
{
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
}
if (!empty($conf->global->MAIN_UMASK))
{
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
}
}
/**
@ -467,27 +468,27 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
*/
function format_cal($format, $string)
{
global $conf;
global $conf;
$newstring = $string;
$newstring = $string;
if ($format === "vcal")
{
$newstring = quotedPrintEncode($newstring);
}
if ($format === "vcal")
{
$newstring = quotedPrintEncode($newstring);
}
if ($format === "ical")
{
// Replace new lines chars by "\n"
$newstring = preg_replace("/"."\r\n"."/i", "\\n", $newstring);
$newstring = preg_replace("/"."\n\r"."/i", "\\n", $newstring);
$newstring = preg_replace("/"."\n"."/i", "\\n", $newstring);
if ($format === "ical")
{
// Replace new lines chars by "\n"
$newstring = preg_replace("/"."\r\n"."/i", "\\n", $newstring);
$newstring = preg_replace("/"."\n\r"."/i", "\\n", $newstring);
$newstring = preg_replace("/"."\n"."/i", "\\n", $newstring);
// Must not exceed 75 char. Cut with "\r\n"+Space
$newstring = calEncode($newstring);
}
// Must not exceed 75 char. Cut with "\r\n"+Space
$newstring = calEncode($newstring);
}
return $newstring;
return $newstring;
}
/**
@ -499,56 +500,56 @@ function format_cal($format, $string)
*/
function calEncode($line)
{
$out = "";
$newpara = "";
$out = "";
$newpara = "";
// If mb_ functions exists, it"s better to use them
if (function_exists("mb_strlen"))
{
$strlength = mb_strlen($line, "UTF-8");
// If mb_ functions exists, it"s better to use them
if (function_exists("mb_strlen"))
{
$strlength = mb_strlen($line, "UTF-8");
for ($j = 0; $j < $strlength; $j++)
{
// Take char at position $j
$char = mb_substr($line, $j, 1, "UTF-8");
for ($j = 0; $j < $strlength; $j++)
{
// Take char at position $j
$char = mb_substr($line, $j, 1, "UTF-8");
if ((mb_strlen($newpara, "UTF-8") + mb_strlen($char, "UTF-8")) >= 75)
{
// CRLF + Space for cal
$out .= $newpara."\r\n ";
if ((mb_strlen($newpara, "UTF-8") + mb_strlen($char, "UTF-8")) >= 75)
{
// CRLF + Space for cal
$out .= $newpara."\r\n ";
$newpara = "";
}
$newpara = "";
}
$newpara .= $char;
}
$newpara .= $char;
}
$out .= $newpara;
}
else
{
$strlength = dol_strlen($line);
$out .= $newpara;
}
else
{
$strlength = dol_strlen($line);
for ($j = 0; $j < $strlength; $j++)
{
// Take char at position $j
$char = substr($line, $j, 1);
for ($j = 0; $j < $strlength; $j++)
{
// Take char at position $j
$char = substr($line, $j, 1);
if ((dol_strlen($newpara) + dol_strlen($char)) >= 75)
{
// CRLF + Space for cal
$out .= $newpara."\r\n ";
if ((dol_strlen($newpara) + dol_strlen($char)) >= 75)
{
// CRLF + Space for cal
$out .= $newpara."\r\n ";
$newpara = "";
}
$newpara = "";
}
$newpara .= $char;
}
$newpara .= $char;
}
$out .= $newpara;
}
$out .= $newpara;
}
return trim($out);
return trim($out);
}
@ -561,45 +562,45 @@ function calEncode($line)
*/
function quotedPrintEncode($str, $forcal = 0)
{
$lines = preg_split("/\r\n/", $str);
$out = "";
$lines = preg_split("/\r\n/", $str);
$out = "";
foreach ($lines as $line)
{
$newpara = "";
foreach ($lines as $line)
{
$newpara = "";
// Do not use dol_strlen here, we need number of bytes
$strlength = strlen($line);
// Do not use dol_strlen here, we need number of bytes
$strlength = strlen($line);
for ($j = 0; $j < $strlength; $j++)
{
$char = substr($line, $j, 1);
$ascii = ord($char);
for ($j = 0; $j < $strlength; $j++)
{
$char = substr($line, $j, 1);
$ascii = ord($char);
if ($ascii < 32 || $ascii === 61 || $ascii > 126)
{
$char = "=".strtoupper(sprintf("%02X", $ascii));
}
if ($ascii < 32 || $ascii === 61 || $ascii > 126)
{
$char = "=".strtoupper(sprintf("%02X", $ascii));
}
// Do not use dol_strlen here, we need number of bytes
if ((strlen($newpara) + strlen($char)) >= 76)
{
// New line with carray-return (CR) and line-feed (LF)
$out .= $newpara."="."\r\n";
// Do not use dol_strlen here, we need number of bytes
if ((strlen($newpara) + strlen($char)) >= 76)
{
// New line with carray-return (CR) and line-feed (LF)
$out .= $newpara."="."\r\n";
// extra space for cal
if ($forcal)
$out .= " ";
// extra space for cal
if ($forcal)
$out .= " ";
$newpara = "";
}
$newpara = "";
}
$newpara .= $char;
}
$newpara .= $char;
}
$out .= $newpara;
}
return trim($out);
$out .= $newpara;
}
return trim($out);
}
/**
@ -610,5 +611,5 @@ function quotedPrintEncode($str, $forcal = 0)
*/
function quotedPrintDecode($str)
{
return trim(quoted_printable_decode(preg_replace("/=\r?\n/", "", $str)));
return trim(quoted_printable_decode(preg_replace("/=\r?\n/", "", $str)));
}

View File

@ -364,14 +364,14 @@ class pdf_crabe extends ModelePDFFactures
// If a certificate is found
if ($cert) {
$info = array(
'Name' => $this->emetteur->name,
'Name' => $this->emetteur->name,
'Location' => getCountry($this->emetteur->country_code, 0),
'Reason' => 'INVOICE',
'ContactInfo' => $this->emetteur->email
);
$pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info);
}
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Set $this->atleastonediscount if you have at least one discount

File diff suppressed because it is too large Load Diff

View File

@ -128,14 +128,14 @@ class modSociete extends DolibarrModules
$r++;
$this->boxes[$r][1] = "box_prospect.php";
$r++;
$this->boxes[$r][1] = "box_contacts.php";
$r++;
$this->boxes[$r][1] = "box_activity.php";
$this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)';
$r++;
$this->boxes[$r][1] = "box_goodcustomers.php";
$this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)';
$r++;
$this->boxes[$r][1] = "box_contacts.php";
$r++;
$this->boxes[$r][1] = "box_activity.php";
$this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)';
$r++;
$this->boxes[$r][1] = "box_goodcustomers.php";
$this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)';
$r++;
// Permissions
$this->rights = array();
$this->rights_class = 'societe';
@ -148,7 +148,7 @@ class modSociete extends DolibarrModules
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'lire';
/*$r++;
/*$r++;
$this->rights[$r][0] = 241;
$this->rights[$r][1] = 'Read thirdparties customers';
$this->rights[$r][2] = 'r';
@ -172,7 +172,7 @@ class modSociete extends DolibarrModules
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'creer';
/* $r++;
/* $r++;
$this->rights[$r][0] = 251;
$this->rights[$r][1] = 'Create thirdparties customers';
$this->rights[$r][2] = 'r';
@ -274,8 +274,8 @@ class modSociete extends DolibarrModules
// Add multicompany field
if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
{
$nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1
if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('s.entity'=>'Entity');
$nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1
if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('s.entity'=>'Entity');
}
$keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
@ -304,7 +304,7 @@ class modSociete extends DolibarrModules
$this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id';
@ -338,38 +338,38 @@ class modSociete extends DolibarrModules
's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode",
's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode",
's.client'=>'Customer', 's.fournisseur'=>'Supplier',
's.address'=>'Address', 's.zip'=>"Zip", 's.town'=>"Town", 's.phone'=>'Phone', 's.email'=>"Email",
't.libelle'=>"ThirdPartyType"
's.address'=>'Address', 's.zip'=>"Zip", 's.town'=>"Town", 's.phone'=>'Phone', 's.email'=>"Email",
't.libelle'=>"ThirdPartyType"
);
$this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
$this->export_TypeFields_array[$r] = array(
'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean",
'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text",
'c.fax'=>"Text", 'c.email'=>"Text",
'c.statut'=>"Status",
's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text",
'c.statut'=>"Status",
's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text",
's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text",
's.client'=>"Text", 's.fournisseur'=>"Text",
's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 's.phone'=>"Text", 's.email'=>"Text",
't.libelle'=>"Text"
's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 's.phone'=>"Text", 's.email'=>"Text",
't.libelle'=>"Text"
);
$this->export_entities_array[$r] = array(
's.rowid'=>"company", 's.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company", 's.code_fournisseur'=>"company",
's.code_compta'=>"company", 's.code_compta_fournisseur'=>"company",
's.client'=>"company", 's.fournisseur'=>"company",
's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 's.phone'=>"company", 's.email'=>"company",
't.libelle'=>"company"
's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 's.phone'=>"company", 's.email'=>"company",
't.libelle'=>"company"
); // We define here only fields that use another picto
if (empty($conf->fournisseur->enabled))
{
unset($this->export_fields_array[$r]['s.code_fournisseur']);
unset($this->export_entities_array[$r]['s.code_fournisseur']);
}
$keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
if (empty($conf->fournisseur->enabled))
{
unset($this->export_fields_array[$r]['s.code_fournisseur']);
unset($this->export_entities_array[$r]['s.code_fournisseur']);
}
$keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'socpeople as c';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
@ -377,7 +377,7 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
$this->export_sql_end[$r] .= ' WHERE c.entity IN ('.getEntity('socpeople').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) {
$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';
@ -389,337 +389,338 @@ class modSociete extends DolibarrModules
}
// Imports
//--------
$r = 0;
// Imports
//--------
$r = 0;
// Import list of third parties and attributes
// Import list of third parties and attributes
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = 'ImportDataset_company_1';
$this->import_icon[$r] = 'company';
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon
$this->import_tables_array[$r] = array(
's' => MAIN_DB_PREFIX.'societe',
'extra' => MAIN_DB_PREFIX.'societe_extrafields'
); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r] = array(//field order as per structure of table llx_societe
's.nom' => "Name*",
's.name_alias' => "AliasNameShort",
's.status' => "Status",
's.code_client' => "CustomerCode",
's.code_fournisseur' => "SupplierCode",
's.code_compta' => "CustomerAccountancyCode",
's.code_compta_fournisseur' => "SupplierAccountancyCode",
's.address' => "Address",
's.zip' => "Zip",
's.town' => "Town",
's.fk_departement' => "StateCode",
's.fk_pays' => "CountryCode",
's.phone' => "Phone",
's.fax' => "Fax",
's.url' => "Url",
's.email' => "Email",
's.skype' => "Skype",
's.fk_effectif' => "Staff",
's.fk_typent' => "ThirdPartyType",
"s.fk_forme_juridique" => "JuridicalStatus",
's.siren' => "ProfId1",
's.siret' => "ProfId2",
's.ape' => "ProfId3",
's.idprof4' => "ProfId4",
's.idprof5' => "ProfId5",
's.idprof6' => "ProfId6",
's.tva_intra' => "VATIntraShort",
's.capital' => "Capital",
's.fk_stcomm' => 'ProspectStatus',
's.note_private' => "NotePrivate",
's.note_public' => "NotePublic",
's.client' => "Customer*",
's.fournisseur' => "Supplier*",
's.fk_prospectlevel' => 'ProspectLevel',
's.mode_reglement' => 'PaymentTypeCustomer',
's.cond_reglement' => "PaymentTermsCustomer",
's.mode_reglement_supplier' => 'PaymentTypeSupplier',
's.cond_reglement_supplier' => "PaymentTermsSupplier",
's.tva_assuj' => 'VATIsUsed',
's.barcode' => 'BarCode',
's.default_lang' => 'DefaultLanguage',
's.canvas' => "Canvas",
's.datec' => "DateCreation",
's.fk_multicurrency' => 'MulticurrencyUsed',
's.multicurrency_code' => 'MulticurrencyCurrency'
);
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = array(
's.fk_user_creat' => 'user->id',
'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'societe'
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r] = array(//field order as per structure of table llx_societe
's.code_client' => array('rule' => 'getcustomercodeifauto'),
's.code_fournisseur' => array('rule' => 'getsuppliercodeifauto'),
's.code_compta' => array('rule' => 'getcustomeraccountancycodeifauto'),
's.code_compta_fournisseur' => array('rule' => 'getsupplieraccountancycodeifauto'),
's.fk_departement' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/cstate.class.php',
'class' => 'Cstate',
'method' => 'fetch',
'dict' => 'DictionaryState'
),
's.fk_pays' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry',
'method' => 'fetch',
'dict' => 'DictionaryCountry'
),
's.fk_typent' => array(
'rule' => 'fetchidfromcodeorlabel',
'classfile' => '/core/class/ctypent.class.php',
'class' => 'Ctypent',
'method' => 'fetch',
'dict' => 'DictionaryCompanyType'
),
's.capital' => array('rule' => 'numeric'),
's.fk_stcomm' => array('rule' => 'zeroifnull'),
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r] = array(//field order as per structure of table llx_societe
's.status' => '^[0|1]',
's.fk_typent' => 'id@'.MAIN_DB_PREFIX.'c_typent',
's.client' => '^[0|1|2|3]',
's.fournisseur' => '^[0|1]',
's.mode_reglement' => 'id@'.MAIN_DB_PREFIX.'c_paiement',
's.cond_reglement' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term',
's.mode_reglement_supplier' => 'id@'.MAIN_DB_PREFIX.'c_paiement',
's.cond_reglement_supplier' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term',
's.tva_assuj' => '^[0|1]',
's.fk_multicurrency' => '^[0|1]',
's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$',
's.multicurrency_code' => 'code_iso@'.MAIN_DB_PREFIX.'c_currencies'
);
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = 'ImportDataset_company_1';
$this->import_icon[$r] = 'company';
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon
$this->import_tables_array[$r] = array(
's' => MAIN_DB_PREFIX.'societe',
'extra' => MAIN_DB_PREFIX.'societe_extrafields'
); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r] = array(//field order as per structure of table llx_societe
's.nom' => "Name*",
's.name_alias' => "AliasNameShort",
's.status' => "Status",
's.code_client' => "CustomerCode",
's.code_fournisseur' => "SupplierCode",
's.code_compta' => "CustomerAccountancyCode",
's.code_compta_fournisseur' => "SupplierAccountancyCode",
's.address' => "Address",
's.zip' => "Zip",
's.town' => "Town",
's.fk_departement' => "StateCode",
's.fk_pays' => "CountryCode",
's.phone' => "Phone",
's.fax' => "Fax",
's.url' => "Url",
's.email' => "Email",
's.skype' => "Skype",
's.fk_effectif' => "Staff",
's.fk_typent' => "ThirdPartyType",
"s.fk_forme_juridique" => "JuridicalStatus",
's.siren' => "ProfId1",
's.siret' => "ProfId2",
's.ape' => "ProfId3",
's.idprof4' => "ProfId4",
's.idprof5' => "ProfId5",
's.idprof6' => "ProfId6",
's.tva_intra' => "VATIntraShort",
's.capital' => "Capital",
's.fk_stcomm' => 'ProspectStatus',
's.note_private' => "NotePrivate",
's.note_public' => "NotePublic",
's.client' => "Customer*",
's.fournisseur' => "Supplier*",
's.fk_prospectlevel' => 'ProspectLevel',
's.mode_reglement' => 'PaymentTypeCustomer',
's.cond_reglement' => "PaymentTermsCustomer",
's.mode_reglement_supplier' => 'PaymentTypeSupplier',
's.cond_reglement_supplier' => "PaymentTermsSupplier",
's.tva_assuj' => 'VATIsUsed',
's.barcode' => 'BarCode',
's.default_lang' => 'DefaultLanguage',
's.canvas' => "Canvas",
's.datec' => "DateCreation",
's.fk_multicurrency' => 'MulticurrencyUsed',
's.multicurrency_code' => 'MulticurrencyCurrency'
);
if (! empty($conf->global->PRODUIT_MULTIPRICES)) $this->import_fields_array[$r]['s.price_level']='PriceLevel';
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = array(
's.fk_user_creat' => 'user->id',
'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'societe'
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r] = array(//field order as per structure of table llx_societe
's.code_client' => array('rule' => 'getcustomercodeifauto'),
's.code_fournisseur' => array('rule' => 'getsuppliercodeifauto'),
's.code_compta' => array('rule' => 'getcustomeraccountancycodeifauto'),
's.code_compta_fournisseur' => array('rule' => 'getsupplieraccountancycodeifauto'),
's.fk_departement' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/cstate.class.php',
'class' => 'Cstate',
'method' => 'fetch',
'dict' => 'DictionaryState'
),
's.fk_pays' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry',
'method' => 'fetch',
'dict' => 'DictionaryCountry'
),
's.fk_typent' => array(
'rule' => 'fetchidfromcodeorlabel',
'classfile' => '/core/class/ctypent.class.php',
'class' => 'Ctypent',
'method' => 'fetch',
'dict' => 'DictionaryCompanyType'
),
's.capital' => array('rule' => 'numeric'),
's.fk_stcomm' => array('rule' => 'zeroifnull'),
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r] = array(//field order as per structure of table llx_societe
's.status' => '^[0|1]',
's.fk_typent' => 'id@'.MAIN_DB_PREFIX.'c_typent',
's.client' => '^[0|1|2|3]',
's.fournisseur' => '^[0|1]',
's.mode_reglement' => 'id@'.MAIN_DB_PREFIX.'c_paiement',
's.cond_reglement' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term',
's.mode_reglement_supplier' => 'id@'.MAIN_DB_PREFIX.'c_paiement',
's.cond_reglement_supplier' => 'rowid@'.MAIN_DB_PREFIX.'c_payment_term',
's.tva_assuj' => '^[0|1]',
's.fk_multicurrency' => '^[0|1]',
's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$',
's.multicurrency_code' => 'code_iso@'.MAIN_DB_PREFIX.'c_currencies'
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe
's.nom' => "TPBigCompany",
's.name_alias' => "Alias for TPBigCompany",
's.status' => "0 (closed) / 1 (active)",
's.code_client' => 'eg. CU01-0001 / empty / "auto"',
's.code_fournisseur' => 'eg. SU01-0001 / empty / "auto"',
's.code_compta' => "Code or empty to be auto-created",
's.code_compta_fournisseur' => "Code or empty to be auto-created",
's.address' => "61 Jump Street",
's.zip' => "123456",
's.town' => "Bigtown",
's.fk_departement' => 'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"',
's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"',
's.phone' => "eg: +34123456789",
's.fax' => "eg. +34987654321",
's.url' => "e.g. https://www.mybigcompany.com",
's.email' => "e.g. test@mybigcompany.com",
's.skype' => "Skype name",
's.fk_effectif' => "1/2/3/5: represents one of the five ranges of employees",
's.fk_typent' => 'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.'c_typent"',
's.fk_forme_juridique' => '1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.'c_forme_juridique"',
's.siret' => "",
's.siren' => "",
's.ape' => "",
's.idprof4' => "",
's.idprof5' => "",
's.idprof6' => "",
's.tva_intra' => 'VAT number e.g."FR0123456789"',
's.capital' => "10000",
's.fk_stcomm' => '-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.'c_stcomm"',
's.note_private' => "Example of a PRIVATE note.",
's.note_public' => "Example of a PUBLIC note.",
's.client' => '0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
's.fournisseur' => '0 (not supplier) / 1 (supplier)',
's.fk_prospectlevel' => 'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.'c_prospectlevel"',
's.mode_reglement' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"',
's.cond_reglement' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"',
's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"',
's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"',
's.tva_assuj' => '0 (VAT not used) / 1 (VAT used)',
's.barcode' => '123456789',
's.default_lang' => 'en_US / es_ES etc...matches a language directory in htdocs/langs/',
's.canvas' => "empty / a custom canvas form layout url e.g. mycanvas@mymodule",
's.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
's.fk_multicurrency' => '0 (use system default currency) / 1 (use local currency)',
's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.'c_currencies"'
);
$this->import_updatekeys_array[$r] = array(
's.nom' => 'Name',
's.code_client' => 'CustomerCode',
's.code_fournisseur' => 'SupplierCode',
's.code_compta' => 'CustomerAccountancyCode',
's.code_compta_fournisseur' => 'SupplierAccountancyCode'
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe
's.nom' => "TPBigCompany",
's.name_alias' => "Alias for TPBigCompany",
's.status' => "0 (closed) / 1 (active)",
's.code_client' => 'eg. CU01-0001 / empty / "auto"',
's.code_fournisseur' => 'eg. SU01-0001 / empty / "auto"',
's.code_compta' => "Code or empty to be auto-created",
's.code_compta_fournisseur' => "Code or empty to be auto-created",
's.address' => "61 Jump Street",
's.zip' => "123456",
's.town' => "Bigtown",
's.fk_departement' => 'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"',
's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"',
's.phone' => "eg: +34123456789",
's.fax' => "eg. +34987654321",
's.url' => "e.g. https://www.mybigcompany.com",
's.email' => "e.g. test@mybigcompany.com",
's.skype' => "Skype name",
's.fk_effectif' => "1/2/3/5: represents one of the five ranges of employees",
's.fk_typent' => 'matches field "id" (1-9 etc.) OR "code" (TE_SMALL etc.) in table "'.MAIN_DB_PREFIX.'c_typent"',
's.fk_forme_juridique' => '1/2/3 etc...matches field "code" in table "'.MAIN_DB_PREFIX.'c_forme_juridique"',
's.siret' => "",
's.siren' => "",
's.ape' => "",
's.idprof4' => "",
's.idprof5' => "",
's.idprof6' => "",
's.tva_intra' => 'VAT number e.g."FR0123456789"',
's.capital' => "10000",
's.fk_stcomm' => '-1/0/1/2 etc... matches field "id" in table "'.MAIN_DB_PREFIX.'c_stcomm"',
's.note_private' => "Example of a PRIVATE note.",
's.note_public' => "Example of a PUBLIC note.",
's.client' => '0 (no customer no prospect) / 1 (customer) / 2 (prospect)/ 3 (customer and prospect)',
's.fournisseur' => '0 (not supplier) / 1 (supplier)',
's.fk_prospectlevel' => 'eg. "PL_MEDIUM" matches field "code" in table "'.MAIN_DB_PREFIX.'c_prospectlevel"',
's.mode_reglement' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"',
's.cond_reglement' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"',
's.mode_reglement_supplier' => '1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.'c_paiement"',
's.cond_reglement_supplier' => '1/2/3...matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_payment_term"',
's.tva_assuj' => '0 (VAT not used) / 1 (VAT used)',
's.barcode' => '123456789',
's.default_lang' => 'en_US / es_ES etc...matches a language directory in htdocs/langs/',
's.canvas' => "empty / a custom canvas form layout url e.g. mycanvas@mymodule",
's.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
's.fk_multicurrency' => '0 (use system default currency) / 1 (use local currency)',
's.multicurrency_code' => 'GBP/USD etc... matches field "code_iso" in table "'.MAIN_DB_PREFIX.'c_currencies"'
);
$this->import_updatekeys_array[$r] = array(
's.nom' => 'Name',
's.code_client' => 'CustomerCode',
's.code_fournisseur' => 'SupplierCode',
's.code_compta' => 'CustomerAccountancyCode',
's.code_compta_fournisseur' => 'SupplierAccountancyCode'
);
// Import list of contacts/additional addresses and attributes
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = 'ImportDataset_company_2';
$this->import_icon[$r] = 'contact';
$this->import_entities_array[$r] = array('s.fk_soc' => 'company'); // We define here only fields that use a different icon than the one defined in import_icon
$this->import_tables_array[$r] = array(
's' => MAIN_DB_PREFIX.'socpeople',
'extra' => MAIN_DB_PREFIX.'socpeople_extrafields'
); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r] = array(//field order as per structure of table llx_socpeople
's.datec' => "DateCreation",
's.fk_soc' => 'ThirdPartyName',
's.civility' => 'UserTitle',
's.lastname' => "Lastname*",
's.firstname' => "Firstname",
's.address' => "Address",
's.zip' => "Zip",
's.town' => "Town",
's.fk_departement' => "StateCode",
's.fk_pays' => "CountryCode",
's.birthday' => "BirthdayDate",
's.poste' => "Role",
's.phone' => "Phone",
's.phone_perso' => "PhonePerso",
's.phone_mobile' => "PhoneMobile",
's.fax' => "Fax",
's.email' => "Email",
's.skype' => "Skype",
's.note_private' => "NotePrivate",
's.note_public' => "NotePublic"
);
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on an old database (during a migration for example)
{
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = array(
's.fk_user_creat' => 'user->id',
'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'socpeople'
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r] = array(
's.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
),
's.fk_departement' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/cstate.class.php',
'class' => 'Cstate',
'method' => 'fetch',
'dict' => 'DictionaryState'
),
's.fk_pays' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry',
'method' => 'fetch',
'dict' => 'DictionaryCountry'
),
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r] = array(
's.birthday' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_socpeople
's.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
's.fk_soc' => 'Third Party name eg. TPBigCompany',
's.civility' => 'Title of civility eg: MR...matches field "code" in table "'.MAIN_DB_PREFIX.'c_civility"',
's.lastname' => "lastname or label",
's.firstname' => 'John',
's.address' => '61 Jump street',
's.zip' => '75000',
's.town' => 'Bigtown',
's.fk_departement' => 'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"',
's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"',
's.birthday' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
's.poste' => "Director",
's.phone' => "5551122",
's.phone_perso' => "5551133",
's.phone_mobile' => "5551144",
's.fax' => "5551155",
's.email' => "johnsmith@email.com",
's.skype' => "skype username",
's.note_private' => "My private note",
's.note_public' => "My public note"
);
// Import list of contacts/additional addresses and attributes
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = 'ImportDataset_company_2';
$this->import_icon[$r] = 'contact';
$this->import_entities_array[$r] = array('s.fk_soc' => 'company'); // We define here only fields that use a different icon than the one defined in import_icon
$this->import_tables_array[$r] = array(
's' => MAIN_DB_PREFIX.'socpeople',
'extra' => MAIN_DB_PREFIX.'socpeople_extrafields'
); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r] = array(//field order as per structure of table llx_socpeople
's.datec' => "DateCreation",
's.fk_soc' => 'ThirdPartyName',
's.civility' => 'UserTitle',
's.lastname' => "Lastname*",
's.firstname' => "Firstname",
's.address' => "Address",
's.zip' => "Zip",
's.town' => "Town",
's.fk_departement' => "StateCode",
's.fk_pays' => "CountryCode",
's.birthday' => "BirthdayDate",
's.poste' => "Role",
's.phone' => "Phone",
's.phone_perso' => "PhonePerso",
's.phone_mobile' => "PhoneMobile",
's.fax' => "Fax",
's.email' => "Email",
's.skype' => "Skype",
's.note_private' => "NotePrivate",
's.note_public' => "NotePublic"
);
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on an old database (during a migration for example)
{
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = array(
's.fk_user_creat' => 'user->id',
'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'socpeople'
); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r] = array(
's.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
),
's.fk_departement' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/cstate.class.php',
'class' => 'Cstate',
'method' => 'fetch',
'dict' => 'DictionaryState'
),
's.fk_pays' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry',
'method' => 'fetch',
'dict' => 'DictionaryCountry'
),
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r] = array(
's.birthday' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
's.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_socpeople
's.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
's.fk_soc' => 'Third Party name eg. TPBigCompany',
's.civility' => 'Title of civility eg: MR...matches field "code" in table "'.MAIN_DB_PREFIX.'c_civility"',
's.lastname' => "lastname or label",
's.firstname' => 'John',
's.address' => '61 Jump street',
's.zip' => '75000',
's.town' => 'Bigtown',
's.fk_departement' => 'matches field "code_departement" in table "'.MAIN_DB_PREFIX.'c_departements"',
's.fk_pays' => 'US/FR/DE etc. matches field "code" in table "'.MAIN_DB_PREFIX.'c_country"',
's.birthday' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
's.poste' => "Director",
's.phone' => "5551122",
's.phone_perso' => "5551133",
's.phone_mobile' => "5551144",
's.fax' => "5551155",
's.email' => "johnsmith@email.com",
's.skype' => "skype username",
's.note_private' => "My private note",
's.note_public' => "My public note"
);
// Import Bank Accounts
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "ImportDataset_company_3"; // Translation key
$this->import_icon[$r] = 'company';
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon to the one defined in import_icon
$this->import_tables_array[$r] = array('sr' => MAIN_DB_PREFIX.'societe_rib');
$this->import_fields_array[$r] = array(//field order as per structure of table llx_societe_rib
'sr.label' => "Label*",
'sr.fk_soc' => "ThirdPartyName*",
'sr.datec' => "DateCreation*",
'sr.bank' => "Bank",
'sr.code_banque' => "BankCode",
'sr.code_guichet' => "DeskCode",
'sr.number' => "BankAccountNumber*",
'sr.cle_rib' => "BankAccountNumberKey",
'sr.bic' => "BIC",
'sr.iban_prefix' => "IBAN",
'sr.domiciliation' => "BankAccountDomiciliation",
'sr.proprio' => "BankAccountOwner",
'sr.owner_address' => "BankAccountOwnerAddress",
'sr.default_rib' => 'Default',
'sr.rum' => 'RUM',
// Import Bank Accounts
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "ImportDataset_company_3"; // Translation key
$this->import_icon[$r] = 'company';
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon to the one defined in import_icon
$this->import_tables_array[$r] = array('sr' => MAIN_DB_PREFIX.'societe_rib');
$this->import_fields_array[$r] = array(//field order as per structure of table llx_societe_rib
'sr.label' => "Label*",
'sr.fk_soc' => "ThirdPartyName*",
'sr.datec' => "DateCreation*",
'sr.bank' => "Bank",
'sr.code_banque' => "BankCode",
'sr.code_guichet' => "DeskCode",
'sr.number' => "BankAccountNumber*",
'sr.cle_rib' => "BankAccountNumberKey",
'sr.bic' => "BIC",
'sr.iban_prefix' => "IBAN",
'sr.domiciliation' => "BankAccountDomiciliation",
'sr.proprio' => "BankAccountOwner",
'sr.owner_address' => "BankAccountOwnerAddress",
'sr.default_rib' => 'Default',
'sr.rum' => 'RUM',
'sr.type' => "Type ban is defaut",
);
);
$this->import_convertvalue_array[$r] = array(
'sr.fk_soc' => array(
'rule' => 'fetchidfromref',
'classfile' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
)
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe_rib
'sr.label' => 'eg. "account1"',
'sr.fk_soc' => 'eg. "TPBigCompany"',
'sr.datec' => 'date used for creating direct debit UMR formatted as '.dol_print_date(dol_now(),
'%Y-%m-%d'),
'sr.bank' => 'bank name eg: "ING-Direct"',
'sr.code_banque' => 'account sort code (GB)/Routing number (US) eg. "8456"',
'sr.code_guichet' => "bank code for office/branch",
'sr.number' => 'account number eg. "3333333333"',
'sr.cle_rib' => 'account checksum/control digits (if used) eg. "22"',
'sr.bic' => 'bank identifier eg. "USHINGMMXXX"',
'sr.iban_prefix' => 'complete account IBAN eg. "GB78CPBK08925068637123"',
'sr.domiciliation' => 'bank branch address eg. "PARIS"',
'sr.proprio' => 'name on the bank account',
'sr.owner_address' => 'address of account holder',
'sr.default_rib' => '1 (default account) / 0 (not default)',
'sr.rum' => 'RUM code',
$this->import_convertvalue_array[$r] = array(
'sr.fk_soc' => array(
'rule' => 'fetchidfromref',
'classfile' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
)
);
$this->import_examplevalues_array[$r] = array(//field order as per structure of table llx_societe_rib
'sr.label' => 'eg. "account1"',
'sr.fk_soc' => 'eg. "TPBigCompany"',
'sr.datec' => 'date used for creating direct debit UMR formatted as '.dol_print_date(dol_now(),
'%Y-%m-%d'),
'sr.bank' => 'bank name eg: "ING-Direct"',
'sr.code_banque' => 'account sort code (GB)/Routing number (US) eg. "8456"',
'sr.code_guichet' => "bank code for office/branch",
'sr.number' => 'account number eg. "3333333333"',
'sr.cle_rib' => 'account checksum/control digits (if used) eg. "22"',
'sr.bic' => 'bank identifier eg. "USHINGMMXXX"',
'sr.iban_prefix' => 'complete account IBAN eg. "GB78CPBK08925068637123"',
'sr.domiciliation' => 'bank branch address eg. "PARIS"',
'sr.proprio' => 'name on the bank account',
'sr.owner_address' => 'address of account holder',
'sr.default_rib' => '1 (default account) / 0 (not default)',
'sr.rum' => 'RUM code',
'sr.type' => 'ban',
);
);
// Import Company Sales representatives
$r++;
@ -738,16 +739,16 @@ class modSociete extends DolibarrModules
}
/**
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function init($options = '')
{
*/
public function init($options = '')
{
global $conf, $langs;
// We disable this to prevent pb of modules not correctly disabled

View File

@ -74,7 +74,7 @@ if ($permission)
print '<div class="div-table-responsive-no-min">'."\n";
print '<div class="tagtable tableforcontact centpercent noborder nobordertop allwidth">'."\n";
?>
?>
<form class="tagtr liste_titre">
<div class="tagtd liste_titre"><?php echo $langs->trans("NatureOfContact"); ?></div>
<div class="tagtd liste_titre"><?php echo $langs->trans("ThirdParty"); ?></div>
@ -88,8 +88,8 @@ if ($permission)
if (empty($hideaddcontactforuser))
{
?>
<form class="tagtr impair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
?>
<form class="tagtr impair nohover" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<input type="hidden" name="id" value="<?php echo $object->id; ?>" />
<input type="hidden" name="action" value="addcontact" />
@ -113,9 +113,9 @@ if ($permission)
if (empty($hideaddcontactforthirdparty))
{
?>
?>
<form class="tagtr pair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
<form class="tagtr pair nohover" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<input type="hidden" name="id" value="<?php echo $object->id; ?>" />
<input type="hidden" name="action" value="addcontact" />
@ -128,7 +128,7 @@ if ($permission)
// add company icon before select list
if ($selectedCompany)
{
echo img_object('', 'company', 'class="hideonsmartphone"');
echo img_object('', 'company', 'class="hideonsmartphone"');
}
?>
<?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, '', 'minwidth300imp'); ?>
@ -326,9 +326,9 @@ print "</form>";
print "<!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->\n";
if (is_object($hookmanager)) {
$hookmanager->initHooks(array('contacttpl'));
$parameters = array();
$reshook = $hookmanager->executeHooks('formContactTpl', $parameters, $object, $action);
$hookmanager->initHooks(array('contacttpl'));
$parameters = array();
$reshook = $hookmanager->executeHooks('formContactTpl', $parameters, $object, $action);
}
print "<!-- END PHP TEMPLATE CONTACTS -->\n";

View File

@ -30,170 +30,168 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
*/
class InterfaceTicketEmail extends DolibarrTriggers
{
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i', '', get_class($this));
$this->family = "ticket";
$this->description = "Triggers of the module ticket to send notifications to internal users and to third-parties";
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
$this->picto = 'ticket';
}
$this->name = preg_replace('/^Interface/i', '', get_class($this));
$this->family = "ticket";
$this->description = "Triggers of the module ticket to send notifications to internal users and to third-parties";
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
$this->picto = 'ticket';
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
public function getName()
{
return $this->name;
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
public function getName()
{
return $this->name;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
public function getDesc()
{
return $this->description;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
public function getDesc()
{
return $this->description;
}
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') {
return $langs->trans("Development");
} elseif ($this->version == 'experimental') {
return $langs->trans("Experimental");
} elseif ($this->version == 'dolibarr') {
return DOL_VERSION;
} elseif ($this->version) {
return $this->version;
} else {
return $langs->trans("Unknown");
}
}
if ($this->version == 'development') {
return $langs->trans("Development");
} elseif ($this->version == 'experimental') {
return $langs->trans("Experimental");
} elseif ($this->version == 'dolibarr') {
return DOL_VERSION;
} elseif ($this->version) {
return $this->version;
} else {
return $langs->trans("Unknown");
}
}
/**
* Function called when a Dolibarrr business event is done.
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers
*
* @param string $action Event action code
* @param Object $object Object
* @param User $user Object user
* @param Translate $langs Object langs
* @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{
/**
* Function called when a Dolibarrr business event is done.
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers
*
* @param string $action Event action code
* @param Object $object Object
* @param User $user Object user
* @param Translate $langs Object langs
* @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{
$ok = 0;
if (empty($conf->ticket->enabled)) return 0; // Module not active, we do nothing
switch ($action) {
case 'TICKET_ASSIGNED':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
switch ($action) {
case 'TICKET_ASSIGNED':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id)
{
$userstat = new User($this->db);
$res = $userstat->fetch($object->fk_user_assign);
if ($res > 0)
{
// Send email to notification email
if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id)
{
$userstat = new User($this->db);
$res = $userstat->fetch($object->fk_user_assign);
if ($res > 0)
{
// Send email to notification email
if (empty($conf->global->TICKET_DISABLE_ALL_MAILS))
{
// Init to avoid errors
$filepath = array();
$filename = array();
$mimetype = array();
if (empty($conf->global->TICKET_DISABLE_ALL_MAILS))
{
// Init to avoid errors
$filepath = array();
$filename = array();
$mimetype = array();
// Send email to assigned user
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou');
$message = '<p>'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."</p>";
$message .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
// Extrafields
if (is_array($object->array_options) && count($object->array_options) > 0) {
foreach ($object->array_options as $key => $value) {
$message .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
}
}
// Send email to assigned user
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou');
$message = '<p>'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."</p>";
$message .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
// Extrafields
if (is_array($object->array_options) && count($object->array_options) > 0) {
foreach ($object->array_options as $key => $value) {
$message .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
}
}
$message .= '</ul>';
$message .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
$message .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
$message .= '</ul>';
$message .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
$message .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
$sendto = $userstat->email;
$from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>';
$sendto = $userstat->email;
$from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>';
$message = dol_nl2br($message);
$message = dol_nl2br($message);
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
if ($mailfile->error) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
if ($mailfile->error) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
}
$ok = 1;
}
else
{
$this->error = $userstat->error;
$this->errors = $userstat->errors;
}
}
break;
$ok = 1;
}
else
{
$this->error = $userstat->error;
$this->errors = $userstat->errors;
}
}
break;
case 'TICKET_CREATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
case 'TICKET_CREATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load('ticket');
$langs->load('ticket');
$object->fetch('', $object->track_id); // Should be useless
$object->fetch('', $object->track_id); // Should be useless
// Send email to notification email
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail']))
{
$sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
if ($sendto)
// Send email to notification email
$sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail']))
{
if ($sendto)
{
// Init to avoid errors
$filepath = array();
@ -201,146 +199,146 @@ class InterfaceTicketEmail extends DolibarrTriggers
$mimetype = array();
/* Send email to admin */
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
$message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
$message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>';
// Extrafields
if (is_array($object->array_options) && count($object->array_options) > 0) {
foreach ($object->array_options as $key => $value) {
$message_admin .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
}
}
$message_admin .= '</ul>';
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
$message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
$message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>';
// Extrafields
if (is_array($object->array_options) && count($object->array_options) > 0) {
foreach ($object->array_options as $key => $value) {
$message_admin .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
}
}
$message_admin .= '</ul>';
if ($object->fk_soc > 0) {
$object->fetch_thirdparty();
$message_admin .= '<p>'.$langs->trans('Company').' : '.$object->thirdparty->name.'</p>';
}
if ($object->fk_soc > 0) {
$object->fetch_thirdparty();
$message_admin .= '<p>'.$langs->trans('Company').' : '.$object->thirdparty->name.'</p>';
}
$message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
$message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
$message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
$message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
$message_admin = dol_nl2br($message_admin);
$message_admin = dol_nl2br($message_admin);
$trackid = 'tic'.$object->id;
$trackid = 'tic'.$object->id;
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
if ($mailfile->error) {
dol_syslog($mailfile->error, LOG_DEBUG);
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
if ($mailfile->error) {
dol_syslog($mailfile->error, LOG_DEBUG);
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
}
}
}
// Send email to customer
if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create)
{
$sendto = '';
if (empty($user->socid) && empty($user->email)) {
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
} else {
$sendto = $user->email;
}
{
$sendto = '';
if (empty($user->socid) && empty($user->email)) {
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
} else {
$sendto = $user->email;
}
if ($sendto) {
// Init to avoid errors
$filepath = array();
$filename = array();
$mimetype = array();
if ($sendto) {
// Init to avoid errors
$filepath = array();
$filename = array();
$mimetype = array();
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
$message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
$message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_customer .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message_customer .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message_customer .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
$message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
$message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_customer .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message_customer .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message_customer .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
// Extrafields
foreach ($this->attributes[$object->table_element]['label'] as $key => $value)
{
$enabled = 1;
if ($enabled && isset($this->attributes[$object->table_element]['list'][$key]))
{
$enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
}
$perms = 1;
if ($perms && isset($this->attributes[$object->table_element]['perms'][$key]))
{
$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
}
// Extrafields
foreach ($this->attributes[$object->table_element]['label'] as $key => $value)
{
$enabled = 1;
if ($enabled && isset($this->attributes[$object->table_element]['list'][$key]))
{
$enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
}
$perms = 1;
if ($perms && isset($this->attributes[$object->table_element]['perms'][$key]))
{
$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
}
$qualified = true;
if (empty($enabled)) $qualified = false;
if (empty($perms)) $qualified = false;
$qualified = true;
if (empty($enabled)) $qualified = false;
if (empty($perms)) $qualified = false;
if ($qualified) $message_customer .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
}
if ($qualified) $message_customer .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
}
$message_customer .= '</ul>';
$message_customer .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
$url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
$message_customer .= '<p>'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
$message_customer .= '<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
$message_customer .= '</ul>';
$message_customer .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
$url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
$message_customer .= '<p>'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
$message_customer .= '<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
$message_customer = dol_nl2br($message_customer);
$message_customer = dol_nl2br($message_customer);
$trackid = 'tic'.$object->id;
$trackid = 'tic'.$object->id;
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid);
if ($mailfile->error) {
dol_syslog($mailfile->error, LOG_DEBUG);
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
}
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid);
if ($mailfile->error) {
dol_syslog($mailfile->error, LOG_DEBUG);
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
}
}
$ok = 1;
break;
$ok = 1;
break;
case 'TICKET_DELETE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break;
case 'TICKET_DELETE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break;
case 'TICKET_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break;
case 'TICKET_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break;
case 'TICKET_CLOSE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break;
}
case 'TICKET_CLOSE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break;
}
return $ok;
}
return $ok;
}
}

View File

@ -2553,7 +2553,7 @@ elseif ($id || $ref)
// This is just to generate a delivery receipt
//var_dump($object->linkedObjectsIds['delivery']);
if ($conf->livraison_bon->enabled && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0)
if ($conf->livraison_bon->enabled && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->livraison->creer && empty($object->linkedObjectsIds['delivery']))
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'</a>';
}

View File

@ -34,7 +34,7 @@ GraphInBarsAreLimitedToNMeasures=Grapics are limited to %s measures in 'Bars' mo
OnlyOneFieldForXAxisIsPossible=Only 1 field is currently possible as X-Axis. Only the first selected field has been selected.
AtLeastOneMeasureIsRequired=At least 1 field for measure is required
AtLeastOneXAxisIsRequired=At least 1 field for X-Axis is required
LatestBlogPosts=Latest Blog Posts
Notify_ORDER_VALIDATE=Sales order validated
Notify_ORDER_SENTBYMAIL=Sales order sent by mail
Notify_ORDER_SUPPLIER_SENTBYMAIL=Purchase order sent by email

View File

@ -186,7 +186,7 @@ PlannedWorkload=Planned workload
PlannedWorkloadShort=Workload
ProjectReferers=Related items
ProjectMustBeValidatedFirst=Project must be validated first
FirstAddRessourceToAllocateTime=Assign a user resource to task to allocate time
FirstAddRessourceToAllocateTime=Assign a user resource as contact of project to allocate time
InputPerDay=Input per day
InputPerWeek=Input per week
InputPerMonth=Input per month

View File

@ -113,3 +113,5 @@ CantDisableYourself=You can't disable your own user record
ForceUserExpenseValidator=Force expense report validator
ForceUserHolidayValidator=Force leave request validator
ValidatorIsSupervisorByDefault=By default, the validator is the supervisor of the user. Keep empty to keep this behaviour.
UserPersonalEmail=Personal email
UserPersonalMobile=Personal mobile phone

View File

@ -70,8 +70,8 @@ if ($cancel) $action ='';
if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->service->creer))
{
$error=0;
var_dump(GETPOST("max_prod", 'int'));
for ($i=0; $i < GETPOST("max_prod", 'int'); $i++)
$maxprod = GETPOST("max_prod", 'int');
for ($i=0; $i < $maxprod; $i++)
{
$qty = price2num(GETPOST("prod_qty_".$i, 'alpha'), 'MS');
if ($qty > 0)

View File

@ -87,12 +87,13 @@ class Warehouses extends DolibarrApi
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'WH-%') and (t.date_creation:<:'20160101')"
* @return array Array of warehouse objects
*
* @throws RestException
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $category = 0, $sqlfilters = '')
{
global $db, $conf;
@ -104,7 +105,15 @@ class Warehouses extends DolibarrApi
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as t";
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
}
$sql .= ' WHERE t.entity IN ('.getEntity('stock').')';
// Select warehouses of given category
if ($category > 0) {
$sql .= " AND c.fk_categorie = ".$db->escape($category);
$sql .= " AND c.fk_warehouse = t.rowid ";
}
// Add sql filters
if ($sqlfilters)
{

View File

@ -95,10 +95,11 @@ class Projects extends DolibarrApi
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter projects of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of project objects
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '')
{
global $db, $conf;
@ -114,7 +115,9 @@ class Projects extends DolibarrApi
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql .= " FROM ".MAIN_DB_PREFIX."projet as t";
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_project as c";
}
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql .= ' WHERE t.entity IN ('.getEntity('project').')';
@ -126,6 +129,10 @@ class Projects extends DolibarrApi
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Select projects of given category
if ($category > 0) {
$sql .= " AND c.fk_categorie = ".$db->escape($category)." AND c.fk_project = t.rowid ";
}
// Add sql filters
if ($sqlfilters)
{

View File

@ -131,6 +131,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
/*
* Actions
*/
@ -141,27 +142,27 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$search_user_id = "";
$search_taskref = '';
$search_tasklabel = '';
$search_dtstartday = '';
$search_dtstartmonth = '';
$search_dtstartyear = '';
$search_dtendday = '';
$search_dtendmonth = '';
$search_dtendyear = '';
$search_planedworkload = '';
$search_timespend = '';
$search_progresscalc = '';
$search_progressdeclare = '';
$toselect = '';
$search_array_options = array();
$search_user_id = "";
$search_taskref = '';
$search_tasklabel = '';
$search_dtstartday = '';
$search_dtstartmonth = '';
$search_dtstartyear = '';
$search_dtendday = '';
$search_dtendmonth = '';
$search_dtendyear = '';
$search_planedworkload = '';
$search_timespend = '';
$search_progresscalc = '';
$search_progressdeclare = '';
$toselect = '';
$search_array_options = array();
}
// Mass actions
@ -216,8 +217,8 @@ if ($action == 'createtask' && $user->rights->projet->creer)
{
$error = 0;
// If we use user timezone, we must change also view/list to use user timezone everywhere
//$date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user');
// If we use user timezone, we must change also view/list to use user timezone everywhere
//$date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user');
//$date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user');
$date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear']);
$date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']);
@ -230,7 +231,7 @@ if ($action == 'createtask' && $user->rights->projet->creer)
$action = 'create';
$error++;
}
if (empty($label))
if (empty($label))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'create';
@ -358,7 +359,7 @@ if ($id > 0 || !empty($ref))
$head = project_prepare_head($object);
dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
$param = 'id='.$object->id;
$param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($search_user_id) $param .= '&search_user_id='.urlencode($search_user_id);
if ($search_taskref) $param .= '&search_taskref='.urlencode($search_taskref);
@ -378,116 +379,116 @@ if ($id > 0 || !empty($ref))
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Project card
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
// Title
$morehtmlref .= $object->title;
// Thirdparty
if ($object->thirdparty->id > 0)
{
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref .= '</div>';
$morehtmlref = '<div class="refidno">';
// Title
$morehtmlref .= $object->title;
// Thirdparty
if ($object->thirdparty->id > 0)
{
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref .= '</div>';
// Define a complementary filter for search of next/prev ref.
if (!$user->rights->projet->all->lire)
{
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
$object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
// Define a complementary filter for search of next/prev ref.
if (!$user->rights->projet->all->lire)
{
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
$object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
print '<table class="border tableforfield" width="100%">';
// Usage
print '<tr><td class="tdtop">';
print $langs->trans("Usage");
print '</td>';
print '<td>';
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowOpportunity");
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print '<br>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>';
}
if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
{
print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>';
}
print '</td></tr>';
// Usage
print '<tr><td class="tdtop">';
print $langs->trans("Usage");
print '</td>';
print '<td>';
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowOpportunity");
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print '<br>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>';
}
if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
{
print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>';
}
print '</td></tr>';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
$start = dol_print_date($object->date_start, 'day');
print ($start ? $start : '?');
$end = dol_print_date($object->date_end, 'day');
print ' - ';
print ($end ? $end : '?');
if ($object->hasDelay()) print img_warning("Late");
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
$start = dol_print_date($object->date_start, 'day');
print ($start ? $start : '?');
$end = dol_print_date($object->date_end, 'day');
print ' - ';
print ($end ? $end : '?');
if ($object->hasDelay()) print img_warning("Late");
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
print '<table class="border tableforfield" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($object->description);
print '</td></tr>';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($object->description);
print '</td></tr>';
// Categories
if ($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
print "</td></tr>";
}
// Categories
if ($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
print "</td></tr>";
}
print '</table>';
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
@ -593,9 +594,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
// Other options
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print $hookmanager->resPrint;
if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label']))
if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label']))
{
print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic
}
@ -624,17 +625,17 @@ elseif ($id > 0 || !empty($ref))
print '<br>';
// Link to create task
$linktocreatetaskParam = array();
$linktocreatetaskUserRight = false;
if ($user->rights->projet->all->creer || $user->rights->projet->creer) {
if ($object->public || $userWrite > 0) {
$linktocreatetaskUserRight = true;
} else {
$linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject");
}
}
$linktocreatetaskParam = array();
$linktocreatetaskUserRight = false;
if ($user->rights->projet->all->creer || $user->rights->projet->creer) {
if ($object->public || $userWrite > 0) {
$linktocreatetaskUserRight = true;
} else {
$linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject");
}
}
$linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'&action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam);
$linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -643,7 +644,7 @@ elseif ($id > 0 || !empty($ref))
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$title = $langs->trans("ListOfTasks");
@ -686,7 +687,7 @@ elseif ($id > 0 || !empty($ref))
}
print '<div class="div-table-responsive">';
print '<table id="tablelines" class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
print '<table id="tablelines" class="tagtable nobottom liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
// Fields title search
print '<tr class="liste_titre_filter">';
@ -749,8 +750,8 @@ elseif ($id > 0 || !empty($ref))
print '</td>';
}
// progress resume not searchable
print '<td class="liste_titre right"></td>';
// progress resume not searchable
print '<td class="liste_titre right"></td>';
if ($object->usage_bill_time)
{
@ -807,14 +808,14 @@ elseif ($id > 0 || !empty($ref))
if (count($tasksarray) > 0)
{
// Show all lines in taskarray (recursive function to go down on tree)
// Show all lines in taskarray (recursive function to go down on tree)
$j = 0; $level = 0;
$nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields);
}
else
{
$colspan = 10;
if ($object->usage_bill_time) $colspan += 2;
$colspan = 10;
if ($object->usage_bill_time) $colspan += 2;
print '<tr class="oddeven nobottom"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoTasks").'</span></td></tr>';
}

View File

@ -374,7 +374,7 @@ if ($id > 0 || !empty($ref))
if ($action != 'editline' && $user->rights->projet->creer)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Nature").'</td>';
print '<td>'.$langs->trans("NatureOfContact").'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td>'.$langs->trans("Users").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
@ -389,7 +389,7 @@ if ($id > 0 || !empty($ref))
if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">';
// Ligne ajout pour contact interne
print '<tr class="oddeven">';
print '<tr class="oddeven nohover">';
print '<td class="nowrap">';
print img_object('', 'user').' '.$langs->trans("Users");

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
@ -53,6 +53,7 @@ $projectid = GETPOST('projectid', 'int');
$ref = GETPOST('ref', 'alpha');
$withproject = GETPOST('withproject', 'int');
$project_ref = GETPOST('project_ref', 'alpha');
$tab = GETPOST('tab', 'aZ09');
$search_day = GETPOST('search_day', 'int');
$search_month = GETPOST('search_month', 'int');
@ -620,8 +621,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
if ($withproject)
{
// Tabs for project
if (empty($id)) $tab = 'timespent';
if (empty($id) || $tab == 'timespent') $tab = 'timespent';
else $tab = 'tasks';
$head = project_prepare_head($projectstatic);
dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
@ -958,6 +960,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="projectid" value="'.$projectidforalltimes.'">';
print '<input type="hidden" name="withproject" value="'.$withproject.'">';
print '<input type="hidden" name="tab" value="'.$tab.'">';
if ($massaction == 'generateinvoice')
{
@ -1139,7 +1142,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
print '<td></td>';
print "</tr>\n";
print '<tr class="oddeven">';
print '<tr class="oddeven nohover">';
// Date
print '<td class="maxwidthonsmartphone">';
@ -1149,28 +1152,31 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
print '</td>';
// Task
$nboftasks = 0;
if (empty($id))
{
print '<td class="maxwidthonsmartphone">';
$formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, '');
$nboftasks = $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, '');
print '</td>';
}
// Contributor
print '<td class="maxwidthonsmartphone nowraponall">';
print img_object('', 'user', 'class="hideonsmartphone"');
$contactsofproject = $projectstatic->getListContactId('internal');
if (count($contactsofproject) > 0)
{
print img_object('', 'user', 'class="hideonsmartphone"');
if (in_array($user->id, $contactsofproject)) $userid = $user->id;
else $userid = $contactsofproject[0];
if ($projectstatic->public) $contactsofproject = array();
print $form->select_dolusers((GETPOST('userid', 'int') ?GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200');
print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200');
}
else
{
print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime');
if ($nboftasks) {
print img_error($langs->trans('FirstAddRessourceToAllocateTime')).' '.$langs->trans('FirstAddRessourceToAllocateTime');
}
}
print '</td>';
@ -1202,8 +1208,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
}
print '<td class="center">';
print '<input type="submit" name="save" class="button buttongen marginleftonly marginbottomonly" value="'.$langs->trans("Add").'">';
print '<input type="submit" name="cancel" class="button buttongen marginleftonly" value="'.$langs->trans("Cancel").'">';
print '<input type="submit" name="save" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort" value="'.$langs->trans("Add").'">';
print '<input type="submit" name="cancel" class="button buttongen marginleftonly margintoponlyshort marginbottomonlyshort" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
print '</table>';
@ -1504,9 +1510,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
if (($action == 'editline' || $action == 'splitline') && $_GET['lineid'] == $task_time->rowid)
{
print '<input type="hidden" name="lineid" value="'.$_GET['lineid'].'">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort" name="save" value="'.$langs->trans("Save").'">';
print '<br>';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
print '<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort" name="cancel" value="'.$langs->trans('Cancel').'">';
}
elseif ($user->rights->projet->lire || $user->rights->projet->all->creer) // Read project and enter time consumed on assigned tasks
{
@ -1515,19 +1521,19 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
if ($conf->MAIN_FEATURES_LEVEL >= 2)
{
print '&nbsp;';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&amp;action=splitline&amp;lineid='.$task_time->rowid.$param.'">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&amp;action=splitline&amp;lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
print img_split();
print '</a>';
}
print '&nbsp;';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&amp;action=editline&amp;lineid='.$task_time->rowid.$param.'">';
print '<a class="reposition editfielda" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&amp;action=editline&amp;lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&amp;action=deleteline&amp;lineid='.$task_time->rowid.$param.'">';
print img_delete();
print '<a class="reposition paddingleft" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&amp;action=deleteline&amp;lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';
print img_delete('default', 'class="pictodelete paddingleft"');
print '</a>';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
@ -1544,6 +1550,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0)
print "</tr>\n";
// Add line to split
if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid)

View File

@ -61,270 +61,268 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Add file in email form
if (GETPOST('addfile', 'alpha') && !GETPOST('add', 'alpha')) {
////$res = $object->fetch('','',GETPOST('track_id'));
////if($res > 0)
////{
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
////$res = $object->fetch('','',GETPOST('track_id'));
////if($res > 0)
////{
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Set tmp directory TODO Use a dedicated directory for temp mails files
$vardir = $conf->ticket->dir_output;
$upload_dir_tmp = $vardir.'/temp/'.session_id();
if (!dol_is_dir($upload_dir_tmp)) {
dol_mkdir($upload_dir_tmp);
}
// Set tmp directory TODO Use a dedicated directory for temp mails files
$vardir = $conf->ticket->dir_output;
$upload_dir_tmp = $vardir.'/temp/'.session_id();
if (!dol_is_dir($upload_dir_tmp)) {
dol_mkdir($upload_dir_tmp);
}
dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, '', 0);
$action = 'create_ticket';
////}
dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, '', 0);
$action = 'create_ticket';
////}
}
// Remove file
if (GETPOST('removedfile', 'alpha') && !GETPOST('add', 'alpha')) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Set tmp directory
$vardir = $conf->ticket->dir_output.'/';
$upload_dir_tmp = $vardir.'/temp/'.session_id();
// Set tmp directory
$vardir = $conf->ticket->dir_output.'/';
$upload_dir_tmp = $vardir.'/temp/'.session_id();
// TODO Delete only files that was uploaded from email form
dol_remove_file_process($_POST['removedfile'], 0, 0);
$action = 'create_ticket';
// TODO Delete only files that was uploaded from email form
dol_remove_file_process($_POST['removedfile'], 0, 0);
$action = 'create_ticket';
}
if ($action == 'create_ticket' && GETPOST('add', 'alpha')) {
$error = 0;
$origin_email = GETPOST('email', 'alpha');
if (empty($origin_email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
$action = '';
} else {
// Search company saved with email
$searched_companies = $object->searchSocidByEmail($origin_email, '0');
$error = 0;
$origin_email = GETPOST('email', 'alpha');
if (empty($origin_email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
$action = '';
} else {
// Search company saved with email
$searched_companies = $object->searchSocidByEmail($origin_email, '0');
// Chercher un contact existant avec cette adresse email
// Le premier contact trouvé est utilisé pour déterminer le contact suivi
$contacts = $object->searchContactByEmail($origin_email);
// Chercher un contact existant avec cette adresse email
// Le premier contact trouvé est utilisé pour déterminer le contact suivi
$contacts = $object->searchContactByEmail($origin_email);
// Option to require email exists to create ticket
if (!empty($conf->global->TICKET_EMAIL_MUST_EXISTS) && !$contacts[0]->socid) {
$error++;
array_push($object->errors, $langs->trans("ErrorEmailMustExistToCreateTicket"));
$action = '';
}
}
// Option to require email exists to create ticket
if (!empty($conf->global->TICKET_EMAIL_MUST_EXISTS) && !$contacts[0]->socid) {
$error++;
array_push($object->errors, $langs->trans("ErrorEmailMustExistToCreateTicket"));
$action = '';
}
}
if (!GETPOST("subject", "none")) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")));
$action = '';
} elseif (!GETPOST("message", "none")) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("message")));
$action = '';
}
if (!GETPOST("subject", "none")) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")));
$action = '';
} elseif (!GETPOST("message", "none")) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("message")));
$action = '';
}
// Check email address
if (!isValidEmail($origin_email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorBadEmailAddress", $langs->transnoentities("email")));
$action = '';
}
// Check email address
if (!isValidEmail($origin_email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorBadEmailAddress", $langs->transnoentities("email")));
$action = '';
}
if (!$error) {
$object->db->begin();
if (!$error) {
$object->db->begin();
$object->track_id = generate_random_id(16);
$object->track_id = generate_random_id(16);
$object->subject = GETPOST("subject", "none");
$object->message = GETPOST("message", "none");
$object->origin_email = $origin_email;
$object->subject = GETPOST("subject", "none");
$object->message = GETPOST("message", "none");
$object->origin_email = $origin_email;
$object->type_code = GETPOST("type_code", 'aZ09');
$object->category_code = GETPOST("category_code", 'aZ09');
$object->severity_code = GETPOST("severity_code", 'aZ09');
if (is_array($searched_companies)) {
$object->fk_soc = $searched_companies[0]->id;
}
$object->type_code = GETPOST("type_code", 'aZ09');
$object->category_code = GETPOST("category_code", 'aZ09');
$object->severity_code = GETPOST("severity_code", 'aZ09');
if (is_array($searched_companies)) {
$object->fk_soc = $searched_companies[0]->id;
}
if (is_array($contacts) and count($contacts) > 0) {
$object->fk_soc = $contacts[0]->socid;
$usertoassign = $contacts[0]->id;
}
if (is_array($contacts) and count($contacts) > 0) {
$object->fk_soc = $contacts[0]->socid;
$usertoassign = $contacts[0]->id;
}
$ret = $extrafields->setOptionalsFromPost(null, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
// Generate new ref
$object->ref = $object->getDefaultRef();
if (!is_object($user)) {
$user = new User($db);
}
// Generate new ref
$object->ref = $object->getDefaultRef();
if (!is_object($user)) {
$user = new User($db);
}
$object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later
$object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later
$id = $object->create($user);
if ($id <= 0) {
$error++;
$errors = ($object->error ? array($object->error) : $object->errors);
array_push($object->errors, $object->error ? array($object->error) : $object->errors);
$action = 'create_ticket';
}
$id = $object->create($user);
if ($id <= 0) {
$error++;
$errors = ($object->error ? array($object->error) : $object->errors);
array_push($object->errors, $object->error ? array($object->error) : $object->errors);
$action = 'create_ticket';
}
if (!$error && $id > 0) {
if ($usertoassign > 0) {
$object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0);
}
}
if (!$error && $id > 0) {
if ($usertoassign > 0) {
$object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0);
}
}
if (!$error)
{
$object->db->commit();
$action = "infos_success";
} else {
$object->db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create_ticket';
}
if (!$error)
{
$object->db->commit();
$action = "infos_success";
} else {
$object->db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create_ticket';
}
if (!$error)
{
$res = $object->fetch($id);
if ($res) {
// Create form object
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$formmail = new FormMail($db);
if (!$error)
{
$res = $object->fetch($id);
if ($res) {
// Create form object
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$formmail = new FormMail($db);
// Init to avoid errors
$filepath = array();
$filename = array();
$mimetype = array();
// Init to avoid errors
$filepath = array();
$filename = array();
$mimetype = array();
$attachedfiles = $formmail->get_attached_files();
$filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
$attachedfiles = $formmail->get_attached_files();
$filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
// Send email to customer
// Send email to customer
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id);
$message .= ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody'))."\n\n";
$message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket')."\n";
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id);
$message .= ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody'))."\n\n";
$message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket')."\n";
$url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
$infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', '<a href="'.$url_public_ticket.'">'.$object->track_id.'</a>')."\n";
$infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl')."\n\n";
$url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
$infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', '<a href="'.$url_public_ticket.'">'.$object->track_id.'</a>')."\n";
$infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl')."\n\n";
$message .= dol_nl2br($infos_new_ticket);
$message .= $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->transnoentities('TicketMessageMailSignatureText');
$message .= dol_nl2br($infos_new_ticket);
$message .= $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->transnoentities('TicketMessageMailSignatureText');
$sendto = GETPOST('email', 'alpha');
$sendto = GETPOST('email', 'alpha');
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
$sendtocc = '';
$deliveryreceipt = 0;
$message = dol_nl2br($message);
$message = dol_nl2br($message);
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
if ($mailfile->error || $mailfile->errors) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
if ($mailfile->error || $mailfile->errors) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
// Send email to TICKET_NOTIFICATION_EMAIL_TO
$sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
if ($sendto)
{
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref, $object->track_id);
$message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
$message_admin .= '<li>'.$langs->trans('From').' : '.$object->origin_email.'</li>';
// Send email to TICKET_NOTIFICATION_EMAIL_TO
if (is_array($extrafields->attributes[$object->table_element]['label']))
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
$enabled = 1;
if ($qualified && isset($extrafields->attributes[$object->table_element]['list'][$key]))
{
$enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
}
$perms = 1;
if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$key]))
{
$perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$key], 1);
}
$sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
$qualified = true;
if (empty($enabled) || $enabled == 2) $qualified = false;
if (empty($perms)) $qualified = false;
if ($qualified) $message_admin .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
}
}
if ($sendto)
{
$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref, $object->track_id);
$message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
$message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
$message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
$message_admin .= '<li>'.$langs->trans('From').' : '.$object->origin_email.'</li>';
$message_admin .= '</ul>';
$message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
$message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
if (is_array($extrafields->attributes[$object->table_element]['label']))
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
$enabled = 1;
if ($qualified && isset($extrafields->attributes[$object->table_element]['list'][$key]))
{
$enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
}
$perms = 1;
if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$key]))
{
$perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$key], 1);
}
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
$qualified = true;
if (empty($enabled) || $enabled == 2) $qualified = false;
if (empty($perms)) $qualified = false;
if ($qualified) $message_admin .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
}
}
$message_admin = dol_nl2br($message_admin);
$message_admin .= '</ul>';
$message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
$message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
if ($mailfile->error || $mailfile->errors) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
}
}
$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
$replyto = $from;
// Copy files into ticket directory
$destdir = $conf->ticket->dir_output.'/'.$object->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
}
foreach ($filename as $i => $val) {
dol_move($filepath[$i], $destdir.'/'.$filename[$i], 0, 1);
$formmail->remove_attached_files($i);
}
$message_admin = dol_nl2br($message_admin);
//setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs');
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
if ($mailfile->error || $mailfile->errors) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
} else {
$result = $mailfile->sendfile();
}
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
}
}
// Copy files into ticket directory
$destdir = $conf->ticket->dir_output.'/'.$object->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
}
foreach ($filename as $i => $val) {
dol_move($filepath[$i], $destdir.'/'.$filename[$i], 0, 1);
$formmail->remove_attached_files($i);
}
//setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs');
// Make a redirect to avoid to have ticket submitted twice if we make back
setEventMessages($langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '<strong>'.$object->track_id.'</strong>', '<strong>'.$object->ref.'</strong>'), null, 'warnings');
setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings');
header("Location: index.php");
// Make a redirect to avoid to have ticket submitted twice if we make back
setEventMessages($langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '<strong>'.$object->track_id.'</strong>', '<strong>'.$object->ref.'</strong>'), null, 'warnings');
setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings');
header("Location: index.php");
exit;
}
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
@ -338,9 +336,9 @@ $formticket = new FormTicket($db);
if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)
{
print '<div class="error">'.$langs->trans('TicketPublicInterfaceForbidden').'</div>';
$db->close();
exit();
print '<div class="error">'.$langs->trans('TicketPublicInterfaceForbidden').'</div>';
$db->close();
exit();
}
$arrayofjs = array();
@ -349,34 +347,34 @@ $arrayofcss = array('/opensurvey/css/style.css', '/ticket/css/styles.css.php');
llxHeaderTicket($langs->trans("CreateTicket"), "", 0, 0, $arrayofjs, $arrayofcss);
print '<div style="width:60%; margin: 0 auto;" class="ticketpublicarea">';
print '<div class="ticketpublicarea">';
if ($action != "infos_success") {
$formticket->withfromsocid = isset($socid) ? $socid : $user->socid;
$formticket->withtitletopic = 1;
$formticket->withcompany = 0;
$formticket->withusercreate = 1;
$formticket->fk_user_create = 0;
$formticket->withemail = 1;
$formticket->ispublic = 1;
$formticket->withfile = 2;
$formticket->action = 'create_ticket';
$formticket->withfromsocid = isset($socid) ? $socid : $user->socid;
$formticket->withtitletopic = 1;
$formticket->withcompany = 0;
$formticket->withusercreate = 1;
$formticket->fk_user_create = 0;
$formticket->withemail = 1;
$formticket->ispublic = 1;
$formticket->withfile = 2;
$formticket->action = 'create_ticket';
$formticket->param = array('returnurl' => $_SERVER['PHP_SELF'].($conf->entity > 1 ? '?entity='.$conf->entity : ''));
$formticket->param = array('returnurl' => $_SERVER['PHP_SELF'].($conf->entity > 1 ? '?entity='.$conf->entity : ''));
print load_fiche_titre($langs->trans('NewTicket'), '', '', 0, 0, 'marginleftonly');
print load_fiche_titre($langs->trans('NewTicket'), '', '', 0, 0, 'marginleftonly');
if (empty($conf->global->TICKET_NOTIFICATION_EMAIL_FROM)) {
$langs->load("errors");
print '<div class="error">';
print $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketEmailNotificationFrom")).'<br>';
print $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentities("Ticket"));
print '<div>';
}
else {
print '<div class="info marginleftonly marginrightonly">'.$langs->trans('TicketPublicInfoCreateTicket').'</div>';
$formticket->showForm();
}
if (empty($conf->global->TICKET_NOTIFICATION_EMAIL_FROM)) {
$langs->load("errors");
print '<div class="error">';
print $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketEmailNotificationFrom")).'<br>';
print $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentities("Ticket"));
print '<div>';
}
else {
print '<div class="info marginleftonly marginrightonly">'.$langs->trans('TicketPublicInfoCreateTicket').'</div>';
$formticket->showForm();
}
}
print '</div>';

View File

@ -67,12 +67,12 @@ $arrayofcss = array('/ticket/css/styles.css.php');
llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
print '<div style="margin: 0 auto; width:60%" class="ticketpublicarea">';
print '<div class="ticketpublicarea">';
print '<p style="text-align: center">'.($conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans("TicketPublicDesc")).'</p>';
print '<div class="ticketform">';
print '<a href="create_ticket.php" class=""><div class="index_create orange bigrounded">'.dol_escape_htmltag($langs->trans("CreateTicket")).'</div></a>';
print '<a href="list.php" class=""><div class="index_display blue bigrounded">'.dol_escape_htmltag($langs->trans("ShowListTicketWithTrackId")).'</div></a>';
print '<a href="view.php" class=""><div class="index_display blue bigrounded">'.dol_escape_htmltag($langs->trans("ShowTicketWithTrackId")).'</div></a>';
print '<a href="create_ticket.php" class="butAction marginbottomonly"><div class="index_create bigrounded"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"></span><br>'.dol_escape_htmltag($langs->trans("CreateTicket")).'</div></a>';
print '<a href="list.php" class="butAction marginbottomonly"><div class="index_display bigrounded"><span class="fa fa-list-alt valignmiddle btnTitle-icon"></span><br>'.dol_escape_htmltag($langs->trans("ViewMyTicketList")).'</div></a>';
print '<a href="view.php" class="butAction marginbottomonly"><div class="index_display bigrounded">'.img_picto('', 'ticket').'<br>'.dol_escape_htmltag($langs->trans("ShowTicketWithTrackId")).'</div></a>';
print '<div style="clear:both;"></div>';
print '</div>';
print '</div>';

View File

@ -170,7 +170,7 @@ $arrayofcss = array('/ticket/css/styles.css.php');
llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
print '<div style="margin: 0 auto; width:60%" class="ticketpublicarea">';
print '<div class="ticketpublicarealist">';
if ($action == "view_ticketlist")
{

View File

@ -23,15 +23,15 @@
*/
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
define('NOCSRFCHECK', '1');
}
// Do not check anti CSRF attack test
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
define('NOREQUIREMENU', '1');
}
// If there is no need to load and show top and left menu
if (!defined("NOLOGIN")) {
define("NOLOGIN", '1');
define("NOLOGIN", '1');
}
// If this page is public (can be called outside logged session)
@ -54,10 +54,10 @@ $action = GETPOST('action', 'aZ09');
$email = GETPOST('email', 'alpha');
if (GETPOST('btn_view_ticket')) {
unset($_SESSION['email_customer']);
unset($_SESSION['email_customer']);
}
if (isset($_SESSION['email_customer'])) {
$email = $_SESSION['email_customer'];
$email = $_SESSION['email_customer'];
}
$object = new ActionsTicket($db);
@ -78,121 +78,121 @@ if ($cancel)
}
if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close" || $action == "add_message") {
$error = 0;
$display_ticket = false;
if (!strlen($track_id)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTrackId")));
$action = '';
}
if (!strlen($email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
$action = '';
} else {
if (!isValidEmail($email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorEmailInvalid"));
$action = '';
}
}
$error = 0;
$display_ticket = false;
if (!strlen($track_id)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTrackId")));
$action = '';
}
if (!strlen($email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
$action = '';
} else {
if (!isValidEmail($email)) {
$error++;
array_push($object->errors, $langs->trans("ErrorEmailInvalid"));
$action = '';
}
}
if (!$error) {
$ret = $object->fetch('', '', $track_id);
if ($ret && $object->dao->id > 0) {
// Check if emails provided is the one of author
$emailofticket = CMailFile::getValidAddress($object->dao->origin_email, 2);
if ($emailofticket == $email)
{
$display_ticket = true;
$_SESSION['email_customer'] = $email;
}
// Check if emails provided is inside list of contacts
else {
$contacts = $object->dao->liste_contact(-1, 'external');
foreach ($contacts as $contact) {
if ($contact['email'] == $email) {
$display_ticket = true;
$_SESSION['email_customer'] = $email;
break;
} else {
$display_ticket = false;
}
}
}
// Check email of thirdparty of ticket
if ($object->dao->fk_soc > 0 || $object->dao->socid > 0) {
$object->dao->fetch_thirdparty();
if ($email == $object->dao->thirdparty->email) {
$display_ticket = true;
$_SESSION['email_customer'] = $email;
}
}
// Check if email is email of creator
if ($object->dao->fk_user_create > 0)
{
$tmpuser = new User($db);
$tmpuser->fetch($object->dao->fk_user_create);
if ($email == $tmpuser->email) {
$display_ticket = true;
$_SESSION['email_customer'] = $email;
}
}
// Check if email is email of creator
if ($object->dao->fk_user_assign > 0 && $object->dao->fk_user_assign != $object->dao->fk_user_create)
{
$tmpuser = new User($db);
$tmpuser->fetch($object->dao->fk_user_assign);
if ($email == $tmpuser->email) {
$display_ticket = true;
$_SESSION['email_customer'] = $email;
}
}
} else {
$error++;
array_push($object->errors, $langs->trans("ErrorTicketNotFound", $track_id));
$action = '';
}
}
if (!$error) {
$ret = $object->fetch('', '', $track_id);
if ($ret && $object->dao->id > 0) {
// Check if emails provided is the one of author
$emailofticket = CMailFile::getValidAddress($object->dao->origin_email, 2);
if ($emailofticket == $email)
{
$display_ticket = true;
$_SESSION['email_customer'] = $email;
}
// Check if emails provided is inside list of contacts
else {
$contacts = $object->dao->liste_contact(-1, 'external');
foreach ($contacts as $contact) {
if ($contact['email'] == $email) {
$display_ticket = true;
$_SESSION['email_customer'] = $email;
break;
} else {
$display_ticket = false;
}
}
}
// Check email of thirdparty of ticket
if ($object->dao->fk_soc > 0 || $object->dao->socid > 0) {
$object->dao->fetch_thirdparty();
if ($email == $object->dao->thirdparty->email) {
$display_ticket = true;
$_SESSION['email_customer'] = $email;
}
}
// Check if email is email of creator
if ($object->dao->fk_user_create > 0)
{
$tmpuser = new User($db);
$tmpuser->fetch($object->dao->fk_user_create);
if ($email == $tmpuser->email) {
$display_ticket = true;
$_SESSION['email_customer'] = $email;
}
}
// Check if email is email of creator
if ($object->dao->fk_user_assign > 0 && $object->dao->fk_user_assign != $object->dao->fk_user_create)
{
$tmpuser = new User($db);
$tmpuser->fetch($object->dao->fk_user_assign);
if ($email == $tmpuser->email) {
$display_ticket = true;
$_SESSION['email_customer'] = $email;
}
}
} else {
$error++;
array_push($object->errors, $langs->trans("ErrorTicketNotFound", $track_id));
$action = '';
}
}
if (!$error && $action == 'confirm_public_close' && $display_ticket)
{
if ($object->dao->close($user)) {
setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
if (!$error && $action == 'confirm_public_close' && $display_ticket)
{
if ($object->dao->close($user)) {
setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
$url = 'view.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
header("Location: ".$url);
} else {
$action = '';
setEventMessages($object->error, $object->errors, 'errors');
}
}
$url = 'view.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
header("Location: ".$url);
} else {
$action = '';
setEventMessages($object->error, $object->errors, 'errors');
}
}
if (!$error && $action == "add_message" && $display_ticket && GETPOSTISSET('btn_add_message'))
{
// TODO Add message...
$ret = $object->dao->newMessage($user, $action, 0);
if (!$error && $action == "add_message" && $display_ticket && GETPOSTISSET('btn_add_message'))
{
// TODO Add message...
$ret = $object->dao->newMessage($user, $action, 0);
if (!$error)
{
$action = 'view_ticket';
}
}
if (!$error)
{
$action = 'view_ticket';
}
}
if ($error || $errors) {
setEventMessages($object->error, $object->errors, 'errors');
if ($action == "add_message")
{
$action = 'presend';
}
else
{
$action = '';
}
}
if ($error || $errors) {
setEventMessages($object->error, $object->errors, 'errors');
if ($action == "add_message")
{
$action = 'presend';
}
else
{
$action = '';
}
}
}
//var_dump($action);
//$object->doActions($action);
@ -224,181 +224,181 @@ $arrayofcss = array('/ticket/css/styles.css.php');
llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
print '<div style="margin: 0 auto;" class="ticketpublicarea">';
print '<div class="ticketpublicarea">';
if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close") {
if ($display_ticket)
{
// Confirmation close
if ($action == 'close') {
print $form->formconfirm($_SERVER["PHP_SELF"]."?track_id=".$track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1);
}
if ($display_ticket)
{
// Confirmation close
if ($action == 'close') {
print $form->formconfirm($_SERVER["PHP_SELF"]."?track_id=".$track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1);
}
print '<div id="form_view_ticket" class="margintoponly">';
print '<div id="form_view_ticket" class="margintoponly">';
print '<table class="ticketpublictable centpercent tableforfield">';
print '<table class="ticketpublictable centpercent tableforfield">';
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $object->dao->ref;
print '</td></tr>';
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $object->dao->ref;
print '</td></tr>';
// Tracking ID
print '<tr><td>'.$langs->trans("TicketTrackId").'</td><td>';
print $object->dao->track_id;
print '</td></tr>';
// Tracking ID
print '<tr><td>'.$langs->trans("TicketTrackId").'</td><td>';
print $object->dao->track_id;
print '</td></tr>';
// Subject
print '<tr><td>'.$langs->trans("Subject").'</td><td>';
print $object->dao->subject;
print '</td></tr>';
// Subject
print '<tr><td>'.$langs->trans("Subject").'</td><td>';
print $object->dao->subject;
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $object->dao->getLibStatut(2);
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $object->dao->getLibStatut(2);
print '</td></tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'</td><td>';
print $object->dao->type_label;
print '</td></tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'</td><td>';
print $object->dao->type_label;
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("Category").'</td><td>';
print $object->dao->category_label;
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("Category").'</td><td>';
print $object->dao->category_label;
print '</td></tr>';
// Severity
print '<tr><td>'.$langs->trans("Severity").'</td><td>';
print $object->dao->severity_label;
print '</td></tr>';
// Severity
print '<tr><td>'.$langs->trans("Severity").'</td><td>';
print $object->dao->severity_label;
print '</td></tr>';
// Creation date
print '<tr><td>'.$langs->trans("DateCreation").'</td><td>';
print dol_print_date($object->dao->datec, 'dayhour');
print '</td></tr>';
// Creation date
print '<tr><td>'.$langs->trans("DateCreation").'</td><td>';
print dol_print_date($object->dao->datec, 'dayhour');
print '</td></tr>';
// Author
print '<tr><td>'.$langs->trans("Author").'</td><td>';
if ($object->dao->fk_user_create > 0) {
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->dao->fk_user_create);
print $fuser->getFullName($langs);
} else {
print dol_escape_htmltag($object->dao->origin_email);
}
// Author
print '<tr><td>'.$langs->trans("Author").'</td><td>';
if ($object->dao->fk_user_create > 0) {
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->dao->fk_user_create);
print $fuser->getFullName($langs);
} else {
print dol_escape_htmltag($object->dao->origin_email);
}
print '</td></tr>';
print '</td></tr>';
// Read date
if (!empty($object->dao->date_read)) {
print '<tr><td>'.$langs->trans("TicketReadOn").'</td><td>';
print dol_print_date($object->dao->date_read, 'dayhour');
print '</td></tr>';
}
// Read date
if (!empty($object->dao->date_read)) {
print '<tr><td>'.$langs->trans("TicketReadOn").'</td><td>';
print dol_print_date($object->dao->date_read, 'dayhour');
print '</td></tr>';
}
// Close date
if (!empty($object->dao->date_close)) {
print '<tr><td>'.$langs->trans("TicketCloseOn").'</td><td>';
print dol_print_date($object->dao->date_close, 'dayhour');
print '</td></tr>';
}
// Close date
if (!empty($object->dao->date_close)) {
print '<tr><td>'.$langs->trans("TicketCloseOn").'</td><td>';
print dol_print_date($object->dao->date_close, 'dayhour');
print '</td></tr>';
}
// User assigned
print '<tr><td>'.$langs->trans("AssignedTo").'</td><td>';
if ($object->dao->fk_user_assign > 0) {
$fuser = new User($db);
$fuser->fetch($object->dao->fk_user_assign);
print $fuser->getFullName($langs, 1);
}
print '</td></tr>';
// User assigned
print '<tr><td>'.$langs->trans("AssignedTo").'</td><td>';
if ($object->dao->fk_user_assign > 0) {
$fuser = new User($db);
$fuser->fetch($object->dao->fk_user_assign);
print $fuser->getFullName($langs, 1);
}
print '</td></tr>';
// Progression
print '<tr><td>'.$langs->trans("Progression").'</td><td>';
print ($object->dao->progress > 0 ? $object->dao->progress : '0').'%';
print '</td></tr>';
// Progression
print '<tr><td>'.$langs->trans("Progression").'</td><td>';
print ($object->dao->progress > 0 ? $object->dao->progress : '0').'%';
print '</td></tr>';
print '</table>';
print '</table>';
print '</div>';
print '</div>';
print '<div style="clear: both; margin-top: 1.5em;"></div>';
print '<div style="clear: both; margin-top: 1.5em;"></div>';
if ($action == 'presend') {
print load_fiche_titre($langs->trans('TicketAddMessage'), '', 'messages@ticket');
if ($action == 'presend') {
print load_fiche_titre($langs->trans('TicketAddMessage'), '', 'messages@ticket');
$formticket = new FormTicket($db);
$formticket = new FormTicket($db);
$formticket->action = "add_message";
$formticket->track_id = $object->dao->track_id;
$formticket->id = $object->dao->id;
$formticket->action = "add_message";
$formticket->track_id = $object->dao->track_id;
$formticket->id = $object->dao->id;
$formticket->param = array('track_id' => $object->dao->track_id, 'fk_user_create' => '-1', 'returnurl' => DOL_URL_ROOT.'/public/ticket/view.php');
$formticket->param = array('track_id' => $object->dao->track_id, 'fk_user_create' => '-1', 'returnurl' => DOL_URL_ROOT.'/public/ticket/view.php');
$formticket->withfile = 2;
$formticket->withcancel = 1;
$formticket->withfile = 2;
$formticket->withcancel = 1;
$formticket->showMessageForm('100%');
}
$formticket->showMessageForm('100%');
}
if ($action != 'presend') {
print '<form method="post" id="form_view_ticket_list" name="form_view_ticket_list" enctype="multipart/form-data" action="'.DOL_URL_ROOT.'/public/ticket/list.php">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="view_ticketlist">';
print '<input type="hidden" name="track_id" value="'.$object->dao->track_id.'">';
print '<input type="hidden" name="email" value="'.$_SESSION['email_customer'].'">';
//print '<input type="hidden" name="search_fk_status" value="non_closed">';
print "</form>\n";
if ($action != 'presend') {
print '<form method="post" id="form_view_ticket_list" name="form_view_ticket_list" enctype="multipart/form-data" action="'.DOL_URL_ROOT.'/public/ticket/list.php">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="view_ticketlist">';
print '<input type="hidden" name="track_id" value="'.$object->dao->track_id.'">';
print '<input type="hidden" name="email" value="'.$_SESSION['email_customer'].'">';
//print '<input type="hidden" name="search_fk_status" value="non_closed">';
print "</form>\n";
print '<div class="tabsAction">';
print '<div class="tabsAction">';
// List ticket
print '<div class="inline-block divButAction"><a class="left" style="padding-right: 50px" href="javascript:$(\'#form_view_ticket_list\').submit();">'.$langs->trans('ViewMyTicketList').'</a></div>';
// List ticket
print '<div class="inline-block divButAction"><a class="left" style="padding-right: 50px" href="javascript:$(\'#form_view_ticket_list\').submit();">'.$langs->trans('ViewMyTicketList').'</a></div>';
if ($object->dao->fk_statut < Ticket::STATUS_CLOSED) {
// New message
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=presend&mode=init&track_id='.$object->dao->track_id.'">'.$langs->trans('AddMessage').'</a></div>';
if ($object->dao->fk_statut < Ticket::STATUS_CLOSED) {
// New message
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=presend&mode=init&track_id='.$object->dao->track_id.'">'.$langs->trans('AddMessage').'</a></div>';
// Close ticket
if ($object->dao->fk_statut >= Ticket::STATUS_NOT_READ && $object->dao->fk_statut < Ticket::STATUS_CLOSED) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=close&track_id='.$object->dao->track_id.'">'.$langs->trans('CloseTicket').'</a></div>';
}
}
// Close ticket
if ($object->dao->fk_statut >= Ticket::STATUS_NOT_READ && $object->dao->fk_statut < Ticket::STATUS_CLOSED) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=close&track_id='.$object->dao->track_id.'">'.$langs->trans('CloseTicket').'</a></div>';
}
}
print '</div>';
}
print '</div>';
}
// Message list
print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket');
$object->viewTicketMessages(false, true, $object->dao);
}
else
{
print '<div class="error">Not Allowed<br><a href="'.$_SERVER['PHP_SELF'].'?track_id='.$object->dao->track_id.'">'.$langs->trans('Back').'</a></div>';
}
// Message list
print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket');
$object->viewTicketMessages(false, true, $object->dao);
}
else
{
print '<div class="error">Not Allowed<br><a href="'.$_SERVER['PHP_SELF'].'?track_id='.$object->dao->track_id.'">'.$langs->trans('Back').'</a></div>';
}
} else {
print '<div class="center opacitymedium margintoponly marginbottomonly">'.$langs->trans("TicketPublicMsgViewLogIn").'</div>';
print '<div class="center opacitymedium margintoponly marginbottomonly">'.$langs->trans("TicketPublicMsgViewLogIn").'</div>';
print '<div id="form_view_ticket">';
print '<form method="post" name="form_view_ticket" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="view_ticket">';
print '<div id="form_view_ticket">';
print '<form method="post" name="form_view_ticket" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="view_ticket">';
print '<p><label for="track_id" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans("TicketTrackId").'</span></label>';
print '<input size="30" id="track_id" name="track_id" value="'.(GETPOST('track_id', 'alpha') ? GETPOST('track_id', 'alpha') : '').'" />';
print '</p>';
print '<p><label for="track_id" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans("TicketTrackId").'</span></label>';
print '<input size="30" id="track_id" name="track_id" value="'.(GETPOST('track_id', 'alpha') ? GETPOST('track_id', 'alpha') : '').'" />';
print '</p>';
print '<p><label for="email" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans('Email').'</span></label>';
print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $_SESSION['customer_email']).'" />';
print '</p>';
print '<p><label for="email" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans('Email').'</span></label>';
print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $_SESSION['customer_email']).'" />';
print '</p>';
print '<p style="text-align: center; margin-top: 1.5em;">';
print '<input class="button" type="submit" name="btn_view_ticket" value="'.$langs->trans('ViewTicket').'" />';
print "</p>\n";
print '<p style="text-align: center; margin-top: 1.5em;">';
print '<input class="button" type="submit" name="btn_view_ticket" value="'.$langs->trans('ViewTicket').'" />';
print "</p>\n";
print "</form>\n";
print "</div>\n";
print "</form>\n";
print "</div>\n";
}
print "</div>";

View File

@ -212,6 +212,8 @@ class Reception extends CommonObject
$this->brouillon = 1;
$this->tracking_number = dol_sanitizeFileName($this->tracking_number);
if (empty($this->fk_project)) $this->fk_project = 0;
if (empty($this->weight_units)) $this->weight_units = 0;
if (empty($this->size_units)) $this->size_units = 0;
$this->user = $user;

View File

@ -108,13 +108,14 @@ class Contacts extends DolibarrApi
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter contacts of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
* @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param int $includecount Count and return also number of elements the contact is used as a link for
* @return array Array of contact objects
*
* @throws RestException
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $includecount = 0)
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $includecount = 0)
{
global $db, $conf;
@ -135,6 +136,9 @@ class Contacts extends DolibarrApi
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_contact as c";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as te ON te.fk_object = t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
// We need this table joined to the select in order to filter by sale
@ -153,6 +157,13 @@ class Contacts extends DolibarrApi
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Select contacts of given category
if ($category > 0) {
$sql .= " AND c.fk_categorie = ".$db->escape($category);
$sql .= " AND c.fk_socpeople = t.rowid ";
}
// Add sql filters
if ($sqlfilters)
{

View File

@ -107,10 +107,11 @@ class Thirdparties extends DolibarrApi
* Set to 2 to show only prospects
* Set to 3 to show only those are not customer neither prospect
* Set to 4 to show only suppliers
* @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.nom:like:'TheCompany%') and (t.date_creation:<:'20160101')"
* @return array Array of thirdparty objects
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '')
{
global $db;
@ -126,15 +127,27 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as t";
if ($category > 0) {
if ($mode != 4) $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
if (!in_array($mode, array(1,2,3))) $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
}
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
$sql .= " WHERE t.fk_stcomm = st.id";
$sql .= " WHERE t.entity IN ('.getEntity('societe').')";
$sql .= " AND t.fk_stcomm = st.id";
if ($mode == 1) $sql .= " AND t.client IN (1, 3)";
if ($mode == 2) $sql .= " AND t.client IN (2, 3)";
if ($mode == 3) $sql .= " AND t.client IN (0)";
if ($mode == 4) $sql .= " AND t.fournisseur IN (1)";
$sql .= ' AND t.entity IN ('.getEntity('societe').')';
// Select thirdparties of given category
if ($category > 0) {
if (!empty($mode) && $mode != 4) { $sql .= " AND c.fk_categorie = ".$db->escape($category)." AND c.fk_soc = t.rowid"; }
elseif (!empty($mode) && $mode == 4) { $sql .= " AND cc.fk_categorie = ".$db->escape($category)." AND cc.fk_soc = t.rowid"; }
else { $sql .= " AND ((c.fk_categorie = ".$db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$db->escape($category)." AND cc.fk_soc = t.rowid))"; }
}
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc";
//if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
if ($socids) $sql .= " AND t.rowid IN (".$socids.")";

View File

@ -14,7 +14,7 @@
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
* Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2019-2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -965,7 +965,7 @@ class Societe extends CommonObject
}
elseif ($rescode == -5)
{
$this->errors[] = 'ErrorprefixRequired';
$this->errors[] = 'ErrorPrefixRequired';
}
$result = -3;
}

View File

@ -58,7 +58,7 @@ span.butAction, span.butActionDelete {
text-transform: uppercase;
font-weight: bold;
margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em !important;
margin: 0em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.9'); ?>em;
padding: 0.6em <?php echo ($dol_optimize_smallscreen ? '0.6' : '0.7'); ?>em;
font-family: <?php print $fontlist ?>;
display: inline-block;

View File

@ -296,6 +296,7 @@ input.buttonpaymentstripe {
a.buttonticket {
padding-left: 5px;
padding-right: 5px;
/* height: 40px; */
}
/* Used by timesheets */
@ -797,9 +798,15 @@ select.flat.selectlimit {
.margintoponly {
margin-top: 10px !important;
}
.margintoponlyshort {
margin-top: 3px !important;
}
.marginbottomonly {
margin-bottom: 10px !important;
}
.marginbottomonlyshort {
margin-bottom: 3px !important;
}
.nomargintop {
margin-top: 0 !important;
}
@ -5817,7 +5824,8 @@ div.tabsElem a.tab {
}
.ticketpublicarea {
width: 70%;
margin-left: 15%;
margin-right: 15%;
}
.publicnewticketform {
/* margin-top: 25px !important; */
@ -5833,7 +5841,8 @@ div.tabsElem a.tab {
padding-left: 5px; padding-right: 5px;
}
.ticketpublicarea {
width: 100% !important;
margin-left: 10px;
margin-right: 10px;
}
}

View File

@ -5808,7 +5808,8 @@ border-top-right-radius: 6px;
/* ============================================================================== */
.ticketpublicarea {
width: 70%;
margin-left: 15%;
margin-right: 15%;
}
.publicnewticketform {
/* margin-top: 25px !important; */
@ -5824,7 +5825,8 @@ border-top-right-radius: 6px;
padding-left: 5px; padding-right: 5px;
}
.ticketpublicarea {
width: 100%;
margin-left: 10px;
margin-right: 10px;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -35,406 +35,406 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
*/
class ActionsTicket
{
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var DoliDB Database handler.
*/
public $db;
public $dao;
public $dao;
public $mesg;
public $mesg;
/**
* @var string Error code (or message)
*/
public $error;
/**
* @var string Error code (or message)
*/
public $error;
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
//! Numero de l'erreur
public $errno = 0;
//! Numero de l'erreur
public $errno = 0;
public $template_dir;
public $template;
public $template_dir;
public $template;
/**
* @var string ticket action label
*/
public $label;
/**
* @var string ticket action label
*/
public $label;
/**
* @var string description
*/
public $description;
/**
* @var string description
*/
public $description;
/**
* @var int ID
*/
public $fk_statut;
/**
* @var int ID
*/
public $fk_statut;
/**
* @var int Thirdparty ID
*/
public $fk_soc;
/**
* @var int Thirdparty ID
*/
public $fk_soc;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
}
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
}
/**
* Instantiation of DAO class
*
* @return void
*/
public function getInstanceDao()
{
if (!is_object($this->dao)) {
$this->dao = new Ticket($this->db);
}
}
/**
* Instantiation of DAO class
*
* @return void
*/
public function getInstanceDao()
{
if (!is_object($this->dao)) {
$this->dao = new Ticket($this->db);
}
}
/**
* Fetch object
*
* @param int $id ID of ticket
* @param string $ref Reference of ticket
* @param string $track_id Track ID of ticket (for public area)
* @return void
*/
public function fetch($id = 0, $ref = '', $track_id = '')
{
$this->getInstanceDao();
return $this->dao->fetch($id, $ref, $track_id);
}
/**
* Fetch object
*
* @param int $id ID of ticket
* @param string $ref Reference of ticket
* @param string $track_id Track ID of ticket (for public area)
* @return void
*/
public function fetch($id = 0, $ref = '', $track_id = '')
{
$this->getInstanceDao();
return $this->dao->fetch($id, $ref, $track_id);
}
/**
* Print statut
*
* @param int $mode Display mode
* @return string Label of status
*/
public function getLibStatut($mode = 0)
{
$this->getInstanceDao();
$this->dao->fk_statut = $this->fk_statut;
return $this->dao->getLibStatut($mode);
}
/**
* Print statut
*
* @param int $mode Display mode
* @return string Label of status
*/
public function getLibStatut($mode = 0)
{
$this->getInstanceDao();
$this->dao->fk_statut = $this->fk_statut;
return $this->dao->getLibStatut($mode);
}
/**
* Get ticket info
*
* @param int $id Object id
* @return void
*/
public function getInfo($id)
{
$this->getInstanceDao();
$this->dao->fetch($id, '', $track_id);
/**
* Get ticket info
*
* @param int $id Object id
* @return void
*/
public function getInfo($id)
{
$this->getInstanceDao();
$this->dao->fetch($id, '', $track_id);
$this->label = $this->dao->label;
$this->description = $this->dao->description;
}
$this->label = $this->dao->label;
$this->description = $this->dao->description;
}
/**
* Get action title
*
* @param string $action Type of action
* @return string Title of action
*/
public function getTitle($action = '')
{
global $langs;
/**
* Get action title
*
* @param string $action Type of action
* @return string Title of action
*/
public function getTitle($action = '')
{
global $langs;
if ($action == 'create') {
return $langs->trans("CreateTicket");
} elseif ($action == 'edit') {
return $langs->trans("EditTicket");
} elseif ($action == 'view') {
return $langs->trans("TicketCard");
} elseif ($action == 'add_message') {
return $langs->trans("AddMessage");
} else {
return $langs->trans("TicketsManagement");
}
}
if ($action == 'create') {
return $langs->trans("CreateTicket");
} elseif ($action == 'edit') {
return $langs->trans("EditTicket");
} elseif ($action == 'view') {
return $langs->trans("TicketCard");
} elseif ($action == 'add_message') {
return $langs->trans("AddMessage");
} else {
return $langs->trans("TicketsManagement");
}
}
/**
* Show ticket original message
*
* @param User $user User wich display
* @param string $action Action mode
* @param Ticket $object Object ticket
* @return void
*/
public function viewTicketOriginalMessage($user, $action, $object)
{
global $conf, $langs;
/**
* Show ticket original message
*
* @param User $user User wich display
* @param string $action Action mode
* @param Ticket $object Object ticket
* @return void
*/
public function viewTicketOriginalMessage($user, $action, $object)
{
global $conf, $langs;
print '<!-- initial message of ticket -->'."\n";
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
// MESSAGE
print '<!-- initial message of ticket -->'."\n";
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
// MESSAGE
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="track_id" value="'.$object->track_id.'">';
print '<input type="hidden" name="action" value="set_message">';
}
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="track_id" value="'.$object->track_id.'">';
print '<input type="hidden" name="action" value="set_message">';
}
// Initial message
print '<div class="underbanner clearboth"></div>';
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent margintable">';
print '<tr class="liste_titre"><td class="nowrap titlefield">';
print $langs->trans("InitialMessage");
print '</td><td>';
if ($user->rights->ticket->manage) {
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=edit_message_init&amp;track_id='.$object->track_id.'">'.img_edit($langs->trans('Modify')).'</a>';
}
print '</td></tr>';
// Initial message
print '<div class="underbanner clearboth"></div>';
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent margintable">';
print '<tr class="liste_titre"><td class="nowrap titlefield">';
print $langs->trans("InitialMessage");
print '</td><td>';
if ($user->rights->ticket->manage) {
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=edit_message_init&amp;track_id='.$object->track_id.'">'.img_edit($langs->trans('Modify')).'</a>';
}
print '</td></tr>';
print '<tr>';
print '<td colspan="2">';
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
// MESSAGE
$msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message;
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$uselocalbrowser = true;
$doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_4, '95%');
$doleditor->Create();
} else {
// Deal with format differences (text / HTML)
if (dol_textishtml($object->message)) {
print $object->message;
} else {
print dol_nl2br($object->message);
}
print '<tr>';
print '<td colspan="2">';
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
// MESSAGE
$msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message;
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$uselocalbrowser = true;
$doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_4, '95%');
$doleditor->Create();
} else {
// Deal with format differences (text / HTML)
if (dol_textishtml($object->message)) {
print $object->message;
} else {
print dol_nl2br($object->message);
}
//print '<div>' . $object->message . '</div>';
}
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
print '<div class="center">';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
print '</div>';
}
print '</td>';
print '</tr>';
print '</table>';
print '</div>';
//print '<div>' . $object->message . '</div>';
}
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
print '<div class="center">';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
print '</div>';
}
print '</td>';
print '</tr>';
print '</table>';
print '</div>';
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
// MESSAGE
print '</form>';
}
}
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
// MESSAGE
print '</form>';
}
}
/**
* View html list of message for ticket
*
* @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action
* @param Ticket $object Object ticket
* @return void
*/
public function viewTicketMessages($show_private, $show_user, $object)
{
global $conf, $langs, $user;
/**
* View html list of message for ticket
*
* @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action
* @param Ticket $object Object ticket
* @return void
*/
public function viewTicketMessages($show_private, $show_user, $object)
{
global $conf, $langs, $user;
// Load logs in cache
$ret = $this->dao->loadCacheMsgsTicket();
if ($ret < 0) dol_print_error($this->dao->db);
// Load logs in cache
$ret = $this->dao->loadCacheMsgsTicket();
if ($ret < 0) dol_print_error($this->dao->db);
$action = GETPOST('action', 'alpha');
$action = GETPOST('action', 'alpha');
$this->viewTicketOriginalMessage($user, $action, $object);
$this->viewTicketOriginalMessage($user, $action, $object);
if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0)
{
print '<table class="border" style="width:100%;">';
if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0)
{
print '<table class="border" style="width:100%;">';
print '<tr class="liste_titre">';
print '<tr class="liste_titre">';
print '<td>';
print $langs->trans('TicketMessagesList');
print '</td>';
print '<td>';
print $langs->trans('TicketMessagesList');
print '</td>';
if ($show_user) {
print '<td>';
print $langs->trans('User');
print '</td>';
}
if ($show_user) {
print '<td>';
print $langs->trans('User');
print '</td>';
}
foreach ($this->dao->cache_msgs_ticket as $id => $arraymsgs) {
if (!$arraymsgs['private']
|| ($arraymsgs['private'] == "1" && $show_private)
) {
//print '<tr>';
print '<tr class="oddeven">';
print '<td><strong>';
print dol_print_date($arraymsgs['datec'], 'dayhour');
print '<strong></td>';
if ($show_user) {
print '<td>';
if ($arraymsgs['fk_user_author'] > 0) {
$userstat = new User($this->db);
$res = $userstat->fetch($arraymsgs['fk_user_author']);
if ($res) {
print $userstat->getNomUrl(0);
}
} else {
print $langs->trans('Customer');
}
print '</td>';
}
print '</td>';
print '<tr class="oddeven">';
print '<td colspan="2">';
print $arraymsgs['message'];
print '</td>';
print '</tr>';
}
}
foreach ($this->dao->cache_msgs_ticket as $id => $arraymsgs) {
if (!$arraymsgs['private']
|| ($arraymsgs['private'] == "1" && $show_private)
) {
//print '<tr>';
print '<tr class="oddeven">';
print '<td><strong>';
print dol_print_date($arraymsgs['datec'], 'dayhour');
print '<strong></td>';
if ($show_user) {
print '<td>';
if ($arraymsgs['fk_user_author'] > 0) {
$userstat = new User($this->db);
$res = $userstat->fetch($arraymsgs['fk_user_author']);
if ($res) {
print $userstat->getNomUrl(0);
}
} else {
print $langs->trans('Customer');
}
print '</td>';
}
print '</td>';
print '<tr class="oddeven">';
print '<td colspan="2">';
print $arraymsgs['message'];
print '</td>';
print '</tr>';
}
}
print '</table>';
} else {
print '<div class="info">'.$langs->trans('NoMsgForThisTicket').'</div>';
}
}
print '</table>';
} else {
print '<div class="info">'.$langs->trans('NoMsgForThisTicket').'</div>';
}
}
/**
* View list of message for ticket with timeline display
*
* @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action
* @param Ticket $object Object ticket
* @return void
*/
public function viewTicketTimelineMessages($show_private, $show_user, Ticket $object)
{
global $conf, $langs, $user;
/**
* View list of message for ticket with timeline display
*
* @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action
* @param Ticket $object Object ticket
* @return void
*/
public function viewTicketTimelineMessages($show_private, $show_user, Ticket $object)
{
global $conf, $langs, $user;
// Load logs in cache
$ret = $object->loadCacheMsgsTicket();
$action = GETPOST('action');
// Load logs in cache
$ret = $object->loadCacheMsgsTicket();
$action = GETPOST('action');
if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) {
print '<section id="cd-timeline">';
if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) {
print '<section id="cd-timeline">';
foreach ($object->cache_msgs_ticket as $id => $arraymsgs) {
if (!$arraymsgs['private']
|| ($arraymsgs['private'] == "1" && $show_private)
) {
print '<div class="cd-timeline-block">';
print '<div class="cd-timeline-img">';
print '<img src="img/messages.png" alt="">';
print '</div> <!-- cd-timeline-img -->';
foreach ($object->cache_msgs_ticket as $id => $arraymsgs) {
if (!$arraymsgs['private']
|| ($arraymsgs['private'] == "1" && $show_private)
) {
print '<div class="cd-timeline-block">';
print '<div class="cd-timeline-img">';
print '<img src="img/messages.png" alt="">';
print '</div> <!-- cd-timeline-img -->';
print '<div class="cd-timeline-content">';
print $arraymsgs['message'];
print '<div class="cd-timeline-content">';
print $arraymsgs['message'];
print '<span class="cd-date">';
print dol_print_date($arraymsgs['datec'], 'dayhour');
print '<span class="cd-date">';
print dol_print_date($arraymsgs['datec'], 'dayhour');
if ($show_user) {
if ($arraymsgs['fk_user_action'] > 0) {
$userstat = new User($this->db);
$res = $userstat->fetch($arraymsgs['fk_user_action']);
if ($res) {
print '<br>';
print $userstat->getNomUrl(1);
}
} else {
print '<br>';
print $langs->trans('Customer');
}
}
print '</span>';
print '</div> <!-- cd-timeline-content -->';
print '</div> <!-- cd-timeline-block -->';
}
}
print '</section>';
} else {
print '<div class="info">'.$langs->trans('NoMsgForThisTicket').'</div>';
}
}
if ($show_user) {
if ($arraymsgs['fk_user_action'] > 0) {
$userstat = new User($this->db);
$res = $userstat->fetch($arraymsgs['fk_user_action']);
if ($res) {
print '<br>';
print $userstat->getNomUrl(1);
}
} else {
print '<br>';
print $langs->trans('Customer');
}
}
print '</span>';
print '</div> <!-- cd-timeline-content -->';
print '</div> <!-- cd-timeline-block -->';
}
}
print '</section>';
} else {
print '<div class="info">'.$langs->trans('NoMsgForThisTicket').'</div>';
}
}
/**
* Print html navbar with link to set ticket status
*
* @param Ticket $object Ticket sup
* @return void
*/
public function viewStatusActions(Ticket $object)
{
global $langs;
/**
* Print html navbar with link to set ticket status
*
* @param Ticket $object Ticket sup
* @return void
*/
public function viewStatusActions(Ticket $object)
{
global $langs;
print '<div class="div-table-responsive-no-min">';
print '<div class="tagtable centpercent">';
print '<div class="tagtr liste_titre">';
// Exclude status which requires specific method
$exclude_status = array(Ticket::STATUS_CLOSED, Ticket::STATUS_CANCELED);
// Exclude actual status
$exclude_status = array_merge($exclude_status, array(intval($object->fk_statut)));
print '<div class="div-table-responsive-no-min margintoponly">';
print '<div class="tagtable centpercent">';
print '<div class="tagtr">';
// Exclude status which requires specific method
$exclude_status = array(Ticket::STATUS_CLOSED, Ticket::STATUS_CANCELED);
// Exclude actual status
$exclude_status = array_merge($exclude_status, array(intval($object->fk_statut)));
// Sort results to be similar to status object list
//sort($exclude_status);
// Sort results to be similar to status object list
//sort($exclude_status);
foreach ($object->statuts_short as $status => $status_label) {
if (!in_array($status, $exclude_status)) {
print '<div class="tagtd center">';
foreach ($object->statuts_short as $status => $status_label) {
if (!in_array($status, $exclude_status)) {
print '<div class="tagtd center">';
if ($status == 1)
{
$urlforbutton = $_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'&action=mark_ticket_read'; // To set as read, we use a dedicated action
}
else
{
$urlforbutton = $_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'&action=set_status&new_status='.$status;
}
if ($status == 1)
{
$urlforbutton = $_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'&action=mark_ticket_read'; // To set as read, we use a dedicated action
}
else
{
$urlforbutton = $_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'&action=set_status&new_status='.$status;
}
print '<a class="button buttonticket" href="'.$urlforbutton.'">';
print img_picto($langs->trans($object->statuts_short[$status]), 'statut'.$status.'.png@ticket').' '.$langs->trans($object->statuts_short[$status]);
print '</a>';
print '</div>';
}
}
print '</div></div></div><br>';
}
print '<a class="butAction buttonticket" href="'.$urlforbutton.'">';
print img_picto($langs->trans($object->statuts_short[$status]), 'statut'.$status.'.png@ticket').' '.$langs->trans($object->statuts_short[$status]);
print '</a>';
print '</div>';
}
}
print '</div></div></div><br>';
}
/**
* Hook to add email element template
*
* @param array $parameters Parameters
* @param Ticket $object Object for action
* @param string $action Action string
* @param HookManager $hookmanager Hookmanager object
* @return int
*/
public function emailElementlist($parameters, &$object, &$action, $hookmanager)
{
global $langs;
/**
* Hook to add email element template
*
* @param array $parameters Parameters
* @param Ticket $object Object for action
* @param string $action Action string
* @param HookManager $hookmanager Hookmanager object
* @return int
*/
public function emailElementlist($parameters, &$object, &$action, $hookmanager)
{
global $langs;
$error = 0;
$error = 0;
if (in_array('admin', explode(':', $parameters['context']))) {
$this->results = array('ticket_send' => $langs->trans('MailToSendTicketMessage'));
}
if (in_array('admin', explode(':', $parameters['context']))) {
$this->results = array('ticket_send' => $langs->trans('MailToSendTicketMessage'));
}
if (!$error) {
return 0; // or return 1 to replace standard code
} else {
$this->errors[] = 'Error message';
return -1;
}
}
if (!$error) {
return 0; // or return 1 to replace standard code
} else {
$this->errors[] = 'Error message';
return -1;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -74,56 +74,13 @@ div.ticketform {
div.ticketform .index_create, .index_display {
display: inline-block;
width: 200px;
height: 58px;
height: 45px;
text-align: center;
vertical-align: middle;
margin: 20px;
text-transform: uppercase;
}
div.ticketform .orange {
color: #fef4e9;
border: solid 1px #da7c0c;
background: #f78d1d;
background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));
background: -moz-linear-gradient(top, #faa51a, #f47a20);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20');
}
div.ticketform .orange:active {
color: #fcd3a5;
background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
background: -moz-linear-gradient(top, #f47a20, #faa51a);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
}
div.ticketform .orange:hover {
background: #f47c20;
background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
background: -moz-linear-gradient(top, #f88e11, #f06015);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
}
div.ticketform .blue {
color: #d9eef7;
border: solid 1px #0076a3;
background: #0095cd;
background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
background: -moz-linear-gradient(top, #00adee, #0078a5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
}
div.ticketform .blue:active {
color: #80bed6;
background: -webkit-gradient(linear, left top, left bottom, from(#0078a5), to(#00adee));
background: -moz-linear-gradient(top, #0078a5, #00adee);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
}
div.ticketform .blue:hover {
background: #007ead;
background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
background: -moz-linear-gradient(top, #0095cc, #00678e);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0095cc', endColorstr='#00678e');
}
#form_create_ticket, #form_view_ticket
{
margin-left: 10px;

View File

@ -145,6 +145,22 @@ if ($action == 'update' && !$cancel)
}
}
// update personal email
if ($action == 'setpersonal_email')
{
$object->personal_email = GETPOST('personal_email');
$result = $object->update($user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// update personal mobile
if ($action == 'setpersonal_mobile')
{
$object->personal_mobile = GETPOST('personal_mobile');
$result = $object->update($user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
/*
* View
@ -197,6 +213,22 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '<td>'.$object->login.'</td>';
print '</tr>';
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer);
print '</td><td>';
print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer, 'email', ($object->personal_email != '' ? dol_print_email($object->personal_email) : ''));
print '</td>';
print '</tr>';
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer);
print '</td><td>';
print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer, 'string', ($object->personal_mobile != '' ? dol_print_phone($object->personal_mobile) : ''));
print '</td>';
print '</tr>';
print '</table>';
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
/* Copyright (C) 2030 Thibault FOUCART <support@ptibogxiv.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -62,10 +63,11 @@ class Users extends DolibarrApi
* @param int $limit Limit for list
* @param int $page Page number
* @param string $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
* @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of User objects
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '')
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $category = 0, $sqlfilters = '')
{
global $db, $conf;
@ -80,8 +82,18 @@ class Users extends DolibarrApi
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."user as t";
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_user as c";
}
$sql .= ' WHERE t.entity IN ('.getEntity('user').')';
if ($user_ids) $sql .= " AND t.rowid IN (".$user_ids.")";
// Select products of given category
if ($category > 0) {
$sql .= " AND c.fk_categorie = ".$db->escape($category);
$sql .= " AND c.fk_user = t.rowid ";
}
// Add sql filters
if ($sqlfilters)
{

View File

@ -936,7 +936,7 @@ if ($action == 'addcontainer')
} else {
$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php';
// Generate the index.php page to be the home page
// Generate the index.php page (to be the home page) and wrapper.php file
$result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper);
if ($result <= 0) setEventMessages('Failed to write file '.$fileindex, null, 'errors');

View File

@ -76,10 +76,10 @@ $original_file = str_replace("../", "/", $original_file);
// Cache or not
if (GETPOST("cache", 'none') || image_format_supported($original_file) >= 0)
{
// Important: Following code is to avoid page request by browser and PHP CPU at
// each Dolibarr page access.
header('Cache-Control: max-age=3600, public, must-revalidate');
header('Pragma: cache'); // This is to avoid having Pragma: no-cache
// Important: Following code is to avoid page request by browser and PHP CPU at
// each Dolibarr page access.
header('Cache-Control: max-age=3600, public, must-revalidate');
header('Pragma: cache'); // This is to avoid having Pragma: no-cache
}
$refname = basename(dirname($original_file)."/");
@ -99,102 +99,107 @@ if ($rss) {
$website->fetch('', $websitekey);
$MAXNEWS = 20;
$arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters);
$eventarray = $arrayofblogs;
$MAXNEWS = 20;
$arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters);
$eventarray = array();
foreach ($arrayofblogs as $blog) {
$blog->fullpageurl = $website->virtualhost.'/'.$blog->pageurl.'.php';
$eventarray[] = $blog;
}
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";
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("build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG);
dol_syslog("build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG);
// Clean parameters
if (!$filename)
{
$extension = 'rss';
$filename = $format.'.'.$extension;
}
// Clean parameters
if (!$filename)
{
$extension = 'rss';
$filename = $format.'.'.$extension;
}
// Create dir and define output file (definitive and temporary)
$result = dol_mkdir($dir_temp);
$outputfile = $dir_temp.'/'.$filename;
// Create dir and define output file (definitive and temporary)
$result = dol_mkdir($dir_temp);
$outputfile = $dir_temp.'/'.$filename;
$result = 0;
$result = 0;
$buildfile = true;
$buildfile = true;
if ($cachedelay)
{
$nowgmt = dol_now();
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay))
{
dol_syslog("build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled");
$buildfile = false;
}
}
if ($cachedelay)
{
$nowgmt = dol_now();
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay))
{
dol_syslog("build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled");
$buildfile = false;
}
}
if ($buildfile)
{
$title = $desc = $langs->transnoentities('LastBlogPosts');
if ($buildfile)
{
$langs->load("other");
$title = $desc = $langs->transnoentities('LatestBlogPosts');
// Create temp file
$outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads
@chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK));
// Create temp file
$outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads
@chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK));
// Write file
$result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp);
// Write file
$result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1');
if ($result >= 0)
{
if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1;
else
{
$error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile;
dol_syslog("build_exportfile ".$error, LOG_ERR);
dol_delete_file($outputfiletmp, 0, 1);
print $error;
exit(-1);
}
}
else
{
dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
dol_delete_file($outputfiletmp, 0, 1);
$langs->load("errors");
print $langs->trans("ErrorFailToCreateFile", $outputfile);
exit(-1);
}
}
if ($result >= 0)
{
if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1;
else
{
$error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile;
dol_syslog("build_exportfile ".$error, LOG_ERR);
dol_delete_file($outputfiletmp, 0, 1);
print $error;
exit(-1);
}
}
else
{
dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
dol_delete_file($outputfiletmp, 0, 1);
$langs->load("errors");
print $langs->trans("ErrorFailToCreateFile", $outputfile);
exit(-1);
}
}
if ($result >= 0)
{
$attachment = false;
if (isset($_GET["attachment"])) $attachment = $_GET["attachment"];
//$attachment = false;
$contenttype = 'application/rss+xml';
if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"];
//$contenttype='text/plain';
$outputencoding = 'UTF-8';
if ($result >= 0)
{
$attachment = false;
if (isset($_GET["attachment"])) $attachment = $_GET["attachment"];
//$attachment = false;
$contenttype = 'application/rss+xml';
if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"];
//$contenttype='text/plain';
$outputencoding = 'UTF-8';
if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : ''));
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : ''));
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
// Ajout directives pour resoudre bug IE
//header('Cache-Control: Public, must-revalidate');
//header('Pragma: public');
if ($cachedelay) header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate');
else header('Cache-Control: private, must-revalidate');
// Ajout directives pour resoudre bug IE
//header('Cache-Control: Public, must-revalidate');
//header('Pragma: public');
if ($cachedelay) header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate');
else header('Cache-Control: private, must-revalidate');
// Clean parameters
$outputfile = $dir_temp.'/'.$filename;
$result = readfile($outputfile);
if (!$result) print 'File '.$outputfile.' was empty.';
// Clean parameters
$outputfile = $dir_temp.'/'.$filename;
$result = readfile($outputfile);
if (!$result) print 'File '.$outputfile.' was empty.';
// header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename));
exit;
}
// header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename));
exit;
}
}
// Get logos
elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file))