Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
803b0eb3bd
@ -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)
|
||||
{
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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&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&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,9 +293,9 @@ 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("Other"), '', '');
|
||||
@ -311,10 +311,10 @@ print "</tr>\n";
|
||||
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">';
|
||||
@ -325,7 +325,7 @@ print '</tr>';
|
||||
print '</table><br>';
|
||||
|
||||
if (!$conf->use_javascript_ajax) {
|
||||
print '</form>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
// Admin var of module
|
||||
@ -342,9 +342,9 @@ 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";
|
||||
}
|
||||
|
||||
// @todo Use module notification instead...
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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');
|
||||
}
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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 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  , strange move of screen when switching value
|
||||
$sellist .= '<option value="-1"> </option>';
|
||||
}
|
||||
// Without  , strange move of screen when switching value
|
||||
$sellist .= '<option value="-1"> </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
File diff suppressed because it is too large
Load Diff
@ -23,8 +23,8 @@
|
||||
*/
|
||||
|
||||
// Define size of logo small and mini
|
||||
$maxwidthsmall = 350; $maxheightsmall = 200; // Near 16/9eme
|
||||
$maxwidthmini = 128; $maxheightmini = 72; // 16/9eme
|
||||
$maxwidthsmall = 350; $maxheightsmall = 200; // Near 16/9eme
|
||||
$maxwidthmini = 128; $maxheightmini = 72; // 16/9eme
|
||||
$quality = 80;
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -338,33 +338,33 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile)
|
||||
*/
|
||||
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,91 +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->fullpageurl ? $event->fullpageurl : $event->pageurl.'.php';
|
||||
$tmpevent['author'] = $event->author_alias ? $event->author_alias : 'unknown';
|
||||
//$tmpevent['category'] = '';
|
||||
$tmpevent['desc'] = $event->description;
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -468,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -500,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);
|
||||
}
|
||||
|
||||
|
||||
@ -562,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -611,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)));
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -43,82 +43,82 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
*/
|
||||
class pdf_sponge extends ModelePDFFactures
|
||||
{
|
||||
/**
|
||||
* @var DoliDb Database handler
|
||||
*/
|
||||
public $db;
|
||||
/**
|
||||
* @var DoliDb Database handler
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string model name
|
||||
*/
|
||||
public $name;
|
||||
* @var string model name
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var string model description (short text)
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* @var int Save the name of generated file as the main doc when generating a doc with this template
|
||||
*/
|
||||
public $update_main_doc_field;
|
||||
* @var string model description (short text)
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* @var string document type
|
||||
*/
|
||||
public $type;
|
||||
* @var int Save the name of generated file as the main doc when generating a doc with this template
|
||||
*/
|
||||
public $update_main_doc_field;
|
||||
|
||||
/**
|
||||
* @var array Minimum version of PHP required by module.
|
||||
* e.g.: PHP ≥ 5.5 = array(5, 5)
|
||||
*/
|
||||
* @var string document type
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var array Minimum version of PHP required by module.
|
||||
* e.g.: PHP ≥ 5.5 = array(5, 5)
|
||||
*/
|
||||
public $phpmin = array(5, 5);
|
||||
|
||||
/**
|
||||
* Dolibarr version of the loaded document
|
||||
* @var string
|
||||
*/
|
||||
* Dolibarr version of the loaded document
|
||||
* @var string
|
||||
*/
|
||||
public $version = 'dolibarr';
|
||||
|
||||
/**
|
||||
* @var int page_largeur
|
||||
*/
|
||||
public $page_largeur;
|
||||
/**
|
||||
* @var int page_largeur
|
||||
*/
|
||||
public $page_largeur;
|
||||
|
||||
/**
|
||||
* @var int page_hauteur
|
||||
*/
|
||||
public $page_hauteur;
|
||||
* @var int page_hauteur
|
||||
*/
|
||||
public $page_hauteur;
|
||||
|
||||
/**
|
||||
* @var array format
|
||||
*/
|
||||
public $format;
|
||||
* @var array format
|
||||
*/
|
||||
public $format;
|
||||
|
||||
/**
|
||||
* @var int marge_gauche
|
||||
*/
|
||||
* @var int marge_gauche
|
||||
*/
|
||||
public $marge_gauche;
|
||||
|
||||
/**
|
||||
* @var int marge_droite
|
||||
*/
|
||||
* @var int marge_droite
|
||||
*/
|
||||
public $marge_droite;
|
||||
|
||||
/**
|
||||
* @var int marge_haute
|
||||
*/
|
||||
* @var int marge_haute
|
||||
*/
|
||||
public $marge_haute;
|
||||
|
||||
/**
|
||||
* @var int marge_basse
|
||||
*/
|
||||
* @var int marge_basse
|
||||
*/
|
||||
public $marge_basse;
|
||||
|
||||
/**
|
||||
* Issuer
|
||||
* @var Societe Object that emits
|
||||
*/
|
||||
/**
|
||||
* Issuer
|
||||
* @var Societe Object that emits
|
||||
*/
|
||||
public $emetteur;
|
||||
|
||||
/**
|
||||
@ -376,7 +376,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
||||
|
||||
// Set certificate
|
||||
$cert=empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
|
||||
$cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
|
||||
// If use has no certificate, we try to take the company one
|
||||
if (!$cert) {
|
||||
$cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT;
|
||||
@ -391,7 +391,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
);
|
||||
$pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info);
|
||||
}
|
||||
|
||||
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
|
||||
// Does we have at least one line with discount $this->atleastonediscount
|
||||
@ -1204,13 +1204,13 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 1;
|
||||
|
||||
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
|
||||
{
|
||||
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
|
||||
{
|
||||
@ -1219,13 +1219,13 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 1;
|
||||
|
||||
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
|
||||
{
|
||||
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
|
||||
$posy = $pdf->GetY() + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1267,10 +1267,10 @@ class pdf_sponge extends ModelePDFFactures
|
||||
{
|
||||
global $conf, $mysoc, $hookmanager;
|
||||
|
||||
$sign = 1;
|
||||
if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
|
||||
$sign = 1;
|
||||
if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$tab2_top = $posy;
|
||||
$tab2_hl = 4;
|
||||
@ -1306,15 +1306,15 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$i = 0;
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
$percent += $line->situation_percent;
|
||||
$i++;
|
||||
$percent += $line->situation_percent;
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!empty($i)) {
|
||||
$avancementGlobal = $percent / $i;
|
||||
$avancementGlobal = $percent / $i;
|
||||
}
|
||||
else {
|
||||
$avancementGlobal = 0;
|
||||
$avancementGlobal = 0;
|
||||
}
|
||||
|
||||
$object->fetchPreviousNextSituationInvoice();
|
||||
@ -1323,98 +1323,98 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$total_a_payer = 0;
|
||||
$total_a_payer_ttc = 0;
|
||||
foreach ($TPreviousIncoice as &$fac) {
|
||||
$total_a_payer += $fac->total_ht;
|
||||
$total_a_payer_ttc += $fac->total_ttc;
|
||||
$total_a_payer += $fac->total_ht;
|
||||
$total_a_payer_ttc += $fac->total_ttc;
|
||||
}
|
||||
$total_a_payer += $object->total_ht;
|
||||
$total_a_payer_ttc += $object->total_ttc;
|
||||
|
||||
if (!empty($avancementGlobal)) {
|
||||
$total_a_payer = $total_a_payer * 100 / $avancementGlobal;
|
||||
$total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
|
||||
$total_a_payer = $total_a_payer * 100 / $avancementGlobal;
|
||||
$total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
|
||||
}
|
||||
else {
|
||||
$total_a_payer = 0;
|
||||
$total_a_payer_ttc = 0;
|
||||
$total_a_payer = 0;
|
||||
$total_a_payer_ttc = 0;
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
if (!empty($TPreviousIncoice)) {
|
||||
$pdf->setY($tab2_top);
|
||||
$posy = $pdf->GetY();
|
||||
$pdf->setY($tab2_top);
|
||||
$posy = $pdf->GetY();
|
||||
|
||||
foreach ($TPreviousIncoice as &$fac) {
|
||||
if ($posy > $this->page_hauteur - 4) {
|
||||
$this->_pagefoot($pdf, $object, $outputlangs, 1);
|
||||
$pdf->addPage();
|
||||
$pdf->setY($this->marge_haute);
|
||||
$posy = $pdf->GetY();
|
||||
}
|
||||
foreach ($TPreviousIncoice as &$fac) {
|
||||
if ($posy > $this->page_hauteur - 4) {
|
||||
$this->_pagefoot($pdf, $object, $outputlangs, 1);
|
||||
$pdf->addPage();
|
||||
$pdf->setY($this->marge_haute);
|
||||
$posy = $pdf->GetY();
|
||||
}
|
||||
|
||||
// cumul TVA précédent
|
||||
$index++;
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $posy);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
// cumul TVA précédent
|
||||
$index++;
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $posy);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$pdf->SetXY($col2x, $posy);
|
||||
$pdf->SetXY($col2x, $posy);
|
||||
|
||||
$facSign = '';
|
||||
if ($i > 1) {
|
||||
$facSign = $fac->total_ht >= 0 ? '+' : '';
|
||||
}
|
||||
$facSign = '';
|
||||
if ($i > 1) {
|
||||
$facSign = $fac->total_ht >= 0 ? '+' : '';
|
||||
}
|
||||
|
||||
$displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
|
||||
$displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
|
||||
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
|
||||
|
||||
$i++;
|
||||
$posy += $tab2_hl;
|
||||
$i++;
|
||||
$posy += $tab2_hl;
|
||||
|
||||
$pdf->setY($posy);
|
||||
}
|
||||
$pdf->setY($posy);
|
||||
}
|
||||
|
||||
// Display current total
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $posy);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
// Display current total
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $posy);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$pdf->SetXY($col2x, $posy);
|
||||
$facSign = '';
|
||||
if ($i > 1) {
|
||||
$facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
|
||||
}
|
||||
$pdf->SetXY($col2x, $posy);
|
||||
$facSign = '';
|
||||
if ($i > 1) {
|
||||
$facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
|
||||
}
|
||||
|
||||
if ($fac->type === facture::TYPE_CREDIT_NOTE) {
|
||||
$facSign = '-'; // les avoirs
|
||||
}
|
||||
if ($fac->type === facture::TYPE_CREDIT_NOTE) {
|
||||
$facSign = '-'; // les avoirs
|
||||
}
|
||||
|
||||
|
||||
$displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
|
||||
$displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
|
||||
|
||||
$posy += $tab2_hl;
|
||||
$posy += $tab2_hl;
|
||||
|
||||
// Display all total
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $posy);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
|
||||
// Display all total
|
||||
$pdf->SetFont('', '', $default_font_size - 1);
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $posy);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
|
||||
|
||||
$pdf->SetXY($col2x, $posy);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
|
||||
$pdf->SetFont('', '', $default_font_size - 2);
|
||||
$pdf->SetXY($col2x, $posy);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
|
||||
$pdf->SetFont('', '', $default_font_size - 2);
|
||||
|
||||
$posy += $tab2_hl;
|
||||
$posy += $tab2_hl;
|
||||
|
||||
if ($posy > $this->page_hauteur - 4) {
|
||||
$pdf->addPage();
|
||||
$pdf->setY($this->marge_haute);
|
||||
$posy = $pdf->GetY();
|
||||
}
|
||||
if ($posy > $this->page_hauteur - 4) {
|
||||
$pdf->addPage();
|
||||
$pdf->setY($this->marge_haute);
|
||||
$posy = $pdf->GetY();
|
||||
}
|
||||
|
||||
$tab2_top = $posy;
|
||||
$index = 0;
|
||||
$tab2_top = $posy;
|
||||
$index = 0;
|
||||
}
|
||||
|
||||
$tab2_top += 3;
|
||||
@ -1425,30 +1425,30 @@ class pdf_sponge extends ModelePDFFactures
|
||||
// Total remise
|
||||
$total_line_remise = 0;
|
||||
foreach ($object->lines as $i => $line) {
|
||||
$total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
|
||||
// Gestion remise sous forme de ligne négative
|
||||
if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
|
||||
$total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
|
||||
// Gestion remise sous forme de ligne négative
|
||||
if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
|
||||
}
|
||||
if ($total_line_remise > 0) {
|
||||
if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
|
||||
if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
|
||||
|
||||
$index++;
|
||||
}
|
||||
// Show total NET before discount
|
||||
if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
|
||||
$index++;
|
||||
}
|
||||
// Show total NET before discount
|
||||
if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
|
||||
|
||||
$index++;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
// Total HT
|
||||
@ -1475,7 +1475,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME amount of vat not supported with multicurrency
|
||||
// FIXME amount of vat not supported with multicurrency
|
||||
|
||||
//Local tax 1 before VAT
|
||||
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
|
||||
@ -1510,7 +1510,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
//}
|
||||
//Local tax 2 before VAT
|
||||
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
|
||||
//{
|
||||
@ -1543,7 +1543,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
//}
|
||||
|
||||
// VAT
|
||||
// Situations totals migth be wrong on huge amounts
|
||||
@ -1554,13 +1554,13 @@ class pdf_sponge extends ModelePDFFactures
|
||||
}
|
||||
|
||||
if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one)
|
||||
if (!empty($sum_pdf_tva))
|
||||
{
|
||||
if (!empty($sum_pdf_tva))
|
||||
{
|
||||
$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
|
||||
}
|
||||
else {
|
||||
$coef_fix_tva = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$coef_fix_tva = 1;
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->tva as $tvakey => $tvaval) {
|
||||
@ -1626,7 +1626,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
//}
|
||||
//Local tax 2 after VAT
|
||||
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
|
||||
//{
|
||||
@ -1636,7 +1636,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
|
||||
foreach ($localtax_rate as $tvakey => $tvaval)
|
||||
{
|
||||
// retrieve global local tax
|
||||
// retrieve global local tax
|
||||
if ($tvakey != 0) // On affiche pas taux 0
|
||||
{
|
||||
//$this->atleastoneratenotnull++;
|
||||
@ -1702,49 +1702,49 @@ class pdf_sponge extends ModelePDFFactures
|
||||
// Retained warranty
|
||||
if (!empty($object->situation_final) && ($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty))))
|
||||
{
|
||||
$displayWarranty = false;
|
||||
$displayWarranty = false;
|
||||
|
||||
// Check if this situation invoice is 100% for real
|
||||
if (!empty($object->situation_final)) {
|
||||
$displayWarranty = true;
|
||||
}
|
||||
elseif (!empty($object->lines) && $object->status == Facture::STATUS_DRAFT) {
|
||||
// $object->situation_final need validation to be done so this test is need for draft
|
||||
$displayWarranty = true;
|
||||
foreach ($object->lines as $i => $line) {
|
||||
if ($line->product_type < 2 && $line->situation_percent < 100) {
|
||||
$displayWarranty = false;
|
||||
break;
|
||||
// Check if this situation invoice is 100% for real
|
||||
if (!empty($object->situation_final)) {
|
||||
$displayWarranty = true;
|
||||
}
|
||||
elseif (!empty($object->lines) && $object->status == Facture::STATUS_DRAFT) {
|
||||
// $object->situation_final need validation to be done so this test is need for draft
|
||||
$displayWarranty = true;
|
||||
foreach ($object->lines as $i => $line) {
|
||||
if ($line->product_type < 2 && $line->situation_percent < 100) {
|
||||
$displayWarranty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($displayWarranty) {
|
||||
$pdf->SetTextColor(40, 40, 40);
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
if ($displayWarranty) {
|
||||
$pdf->SetTextColor(40, 40, 40);
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
|
||||
$retainedWarranty = $total_a_payer_ttc * $object->retained_warranty / 100;
|
||||
$billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
|
||||
$retainedWarranty = $total_a_payer_ttc * $object->retained_warranty / 100;
|
||||
$billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
|
||||
|
||||
// Billed - retained warranty
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
|
||||
// Billed - retained warranty
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
|
||||
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
|
||||
|
||||
// retained warranty
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
// retained warranty
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
|
||||
$retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty").' ('.$object->retained_warranty.'%)';
|
||||
$retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
|
||||
$retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty").' ('.$object->retained_warranty.'%)';
|
||||
$retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
|
||||
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
|
||||
}
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1878,7 +1878,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
|
||||
|
||||
if (empty($hidetop)) {
|
||||
$pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
|
||||
$pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
|
||||
}
|
||||
}
|
||||
|
||||
@ -1906,9 +1906,9 @@ class pdf_sponge extends ModelePDFFactures
|
||||
|
||||
// Show Draft Watermark
|
||||
if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
|
||||
{
|
||||
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
|
||||
}
|
||||
{
|
||||
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
|
||||
}
|
||||
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->SetFont('', 'B', $default_font_size + 3);
|
||||
@ -1916,7 +1916,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
$w = 110;
|
||||
|
||||
$posy = $this->marge_haute;
|
||||
$posx = $this->page_largeur - $this->marge_droite - $w;
|
||||
$posx = $this->page_largeur - $this->marge_droite - $w;
|
||||
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
|
||||
@ -1936,7 +1936,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
}
|
||||
if (is_readable($logo))
|
||||
{
|
||||
$height = pdf_getHeightForLogo($logo);
|
||||
$height = pdf_getHeightForLogo($logo);
|
||||
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
|
||||
}
|
||||
else
|
||||
@ -2088,16 +2088,16 @@ class pdf_sponge extends ModelePDFFactures
|
||||
// Get contact
|
||||
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
|
||||
{
|
||||
$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
|
||||
if (count($arrayidcontact) > 0)
|
||||
{
|
||||
$usertmp = new User($this->db);
|
||||
$usertmp->fetch($arrayidcontact[0]);
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
}
|
||||
$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
|
||||
if (count($arrayidcontact) > 0)
|
||||
{
|
||||
$usertmp = new User($this->db);
|
||||
$usertmp->fetch($arrayidcontact[0]);
|
||||
$posy += 4;
|
||||
$pdf->SetXY($posx, $posy);
|
||||
$pdf->SetTextColor(0, 0, 60);
|
||||
$pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
}
|
||||
}
|
||||
|
||||
$posy += 1;
|
||||
@ -2203,7 +2203,7 @@ class pdf_sponge extends ModelePDFFactures
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||
/**
|
||||
* Show footer of page. Need this->emetteur object
|
||||
*
|
||||
*
|
||||
* @param PDF $pdf PDF
|
||||
* @param Object $object Object to show
|
||||
* @param Translate $outputlangs Object lang for output
|
||||
@ -2222,28 +2222,28 @@ class pdf_sponge extends ModelePDFFactures
|
||||
*
|
||||
* @param object $object common object
|
||||
* @param Translate $outputlangs langs
|
||||
* @param int $hidedetails Do not show line details
|
||||
* @param int $hidedesc Do not show desc
|
||||
* @param int $hideref Do not show ref
|
||||
* @return null
|
||||
*/
|
||||
public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||
{
|
||||
global $conf, $hookmanager;
|
||||
* @param int $hidedetails Do not show line details
|
||||
* @param int $hidedesc Do not show desc
|
||||
* @param int $hideref Do not show ref
|
||||
* @return null
|
||||
*/
|
||||
public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
|
||||
{
|
||||
global $conf, $hookmanager;
|
||||
|
||||
// Default field style for content
|
||||
$this->defaultContentsFieldsStyle = array(
|
||||
'align' => 'R', // R,C,L
|
||||
'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
);
|
||||
// Default field style for content
|
||||
$this->defaultContentsFieldsStyle = array(
|
||||
'align' => 'R', // R,C,L
|
||||
'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
);
|
||||
|
||||
// Default field style for content
|
||||
$this->defaultTitlesFieldsStyle = array(
|
||||
'align' => 'C', // R,C,L
|
||||
'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
);
|
||||
// Default field style for content
|
||||
$this->defaultTitlesFieldsStyle = array(
|
||||
'align' => 'C', // R,C,L
|
||||
'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
);
|
||||
|
||||
/*
|
||||
/*
|
||||
* For exemple
|
||||
$this->cols['theColKey'] = array(
|
||||
'rank' => $rank, // int : use for ordering columns
|
||||
@ -2261,165 +2261,165 @@ class pdf_sponge extends ModelePDFFactures
|
||||
);
|
||||
*/
|
||||
|
||||
$rank = 0; // do not use negative rank
|
||||
$this->cols['desc'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => false, // only for desc
|
||||
'status' => true,
|
||||
'title' => array(
|
||||
'textkey' => 'Designation', // use lang key is usefull in somme case with module
|
||||
'align' => 'L',
|
||||
// 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
|
||||
// 'label' => ' ', // the final label
|
||||
'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
),
|
||||
'content' => array(
|
||||
'align' => 'L',
|
||||
'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
),
|
||||
);
|
||||
$rank = 0; // do not use negative rank
|
||||
$this->cols['desc'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => false, // only for desc
|
||||
'status' => true,
|
||||
'title' => array(
|
||||
'textkey' => 'Designation', // use lang key is usefull in somme case with module
|
||||
'align' => 'L',
|
||||
// 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
|
||||
// 'label' => ' ', // the final label
|
||||
'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
),
|
||||
'content' => array(
|
||||
'align' => 'L',
|
||||
'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
),
|
||||
);
|
||||
|
||||
// PHOTO
|
||||
$rank = $rank + 10;
|
||||
$this->cols['photo'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
|
||||
'status' => false,
|
||||
'title' => array(
|
||||
'textkey' => 'Photo',
|
||||
'label' => ' '
|
||||
),
|
||||
'content' => array(
|
||||
'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
),
|
||||
'border-left' => false, // remove left line separator
|
||||
);
|
||||
// PHOTO
|
||||
$rank = $rank + 10;
|
||||
$this->cols['photo'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
|
||||
'status' => false,
|
||||
'title' => array(
|
||||
'textkey' => 'Photo',
|
||||
'label' => ' '
|
||||
),
|
||||
'content' => array(
|
||||
'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
|
||||
),
|
||||
'border-left' => false, // remove left line separator
|
||||
);
|
||||
|
||||
if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
|
||||
{
|
||||
$this->cols['photo']['status'] = true;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
|
||||
{
|
||||
$this->cols['photo']['status'] = true;
|
||||
}
|
||||
|
||||
|
||||
$rank = $rank + 10;
|
||||
$this->cols['vat'] = array(
|
||||
'rank' => $rank,
|
||||
'status' => false,
|
||||
'width' => 16, // in mm
|
||||
'title' => array(
|
||||
'textkey' => 'VAT'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
$rank = $rank + 10;
|
||||
$this->cols['vat'] = array(
|
||||
'rank' => $rank,
|
||||
'status' => false,
|
||||
'width' => 16, // in mm
|
||||
'title' => array(
|
||||
'textkey' => 'VAT'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
|
||||
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
|
||||
{
|
||||
$this->cols['vat']['status'] = true;
|
||||
}
|
||||
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
|
||||
{
|
||||
$this->cols['vat']['status'] = true;
|
||||
}
|
||||
|
||||
$rank = $rank + 10;
|
||||
$this->cols['subprice'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 19, // in mm
|
||||
'status' => true,
|
||||
'title' => array(
|
||||
'textkey' => 'PriceUHT'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
$rank = $rank + 10;
|
||||
$this->cols['subprice'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 19, // in mm
|
||||
'status' => true,
|
||||
'title' => array(
|
||||
'textkey' => 'PriceUHT'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
|
||||
$rank = $rank + 10;
|
||||
$this->cols['qty'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 16, // in mm
|
||||
'status' => true,
|
||||
'title' => array(
|
||||
'textkey' => 'Qty'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
$rank = $rank + 10;
|
||||
$this->cols['qty'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 16, // in mm
|
||||
'status' => true,
|
||||
'title' => array(
|
||||
'textkey' => 'Qty'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
|
||||
$rank = $rank + 10;
|
||||
$this->cols['progress'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 19, // in mm
|
||||
'status' => false,
|
||||
'title' => array(
|
||||
'textkey' => 'Progress'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
$rank = $rank + 10;
|
||||
$this->cols['progress'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 19, // in mm
|
||||
'status' => false,
|
||||
'title' => array(
|
||||
'textkey' => 'Progress'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
|
||||
if ($this->situationinvoice)
|
||||
{
|
||||
$this->cols['progress']['status'] = true;
|
||||
}
|
||||
if ($this->situationinvoice)
|
||||
{
|
||||
$this->cols['progress']['status'] = true;
|
||||
}
|
||||
|
||||
$rank = $rank + 10;
|
||||
$this->cols['unit'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 11, // in mm
|
||||
'status' => false,
|
||||
'title' => array(
|
||||
'textkey' => 'Unit'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
$this->cols['unit']['status'] = true;
|
||||
}
|
||||
$rank = $rank + 10;
|
||||
$this->cols['unit'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 11, // in mm
|
||||
'status' => false,
|
||||
'title' => array(
|
||||
'textkey' => 'Unit'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
$this->cols['unit']['status'] = true;
|
||||
}
|
||||
|
||||
$rank = $rank + 10;
|
||||
$this->cols['discount'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 13, // in mm
|
||||
'status' => false,
|
||||
'title' => array(
|
||||
'textkey' => 'ReductionShort'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
if ($this->atleastonediscount) {
|
||||
$this->cols['discount']['status'] = true;
|
||||
}
|
||||
$rank = $rank + 10;
|
||||
$this->cols['discount'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 13, // in mm
|
||||
'status' => false,
|
||||
'title' => array(
|
||||
'textkey' => 'ReductionShort'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
if ($this->atleastonediscount) {
|
||||
$this->cols['discount']['status'] = true;
|
||||
}
|
||||
|
||||
$rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
|
||||
$this->cols['totalexcltax'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 26, // in mm
|
||||
'status' => true,
|
||||
'title' => array(
|
||||
'textkey' => 'TotalHT'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
$rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
|
||||
$this->cols['totalexcltax'] = array(
|
||||
'rank' => $rank,
|
||||
'width' => 26, // in mm
|
||||
'status' => true,
|
||||
'title' => array(
|
||||
'textkey' => 'TotalHT'
|
||||
),
|
||||
'border-left' => true, // add left line separator
|
||||
);
|
||||
|
||||
// Add extrafields cols
|
||||
if (!empty($object->lines)) {
|
||||
$line = reset($object->lines);
|
||||
$this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
|
||||
}
|
||||
// Add extrafields cols
|
||||
if (!empty($object->lines)) {
|
||||
$line = reset($object->lines);
|
||||
$this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
|
||||
}
|
||||
|
||||
$parameters = array(
|
||||
'object' => $object,
|
||||
'outputlangs' => $outputlangs,
|
||||
'hidedetails' => $hidedetails,
|
||||
'hidedesc' => $hidedesc,
|
||||
'hideref' => $hideref
|
||||
);
|
||||
$parameters = array(
|
||||
'object' => $object,
|
||||
'outputlangs' => $outputlangs,
|
||||
'hidedetails' => $hidedetails,
|
||||
'hidedesc' => $hidedesc,
|
||||
'hideref' => $hideref
|
||||
);
|
||||
|
||||
$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
|
||||
if ($reshook < 0)
|
||||
{
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
elseif (empty($reshook))
|
||||
{
|
||||
$this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->cols = $hookmanager->resArray;
|
||||
}
|
||||
$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
|
||||
if ($reshook < 0)
|
||||
{
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
elseif (empty($reshook))
|
||||
{
|
||||
$this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->cols = $hookmanager->resArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,338 +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'
|
||||
);
|
||||
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'
|
||||
);
|
||||
$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++;
|
||||
@ -739,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
|
||||
|
||||
@ -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,7 +88,7 @@ if ($permission)
|
||||
|
||||
if (empty($hideaddcontactforuser))
|
||||
{
|
||||
?>
|
||||
?>
|
||||
<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; ?>" />
|
||||
@ -113,7 +113,7 @@ if ($permission)
|
||||
|
||||
if (empty($hideaddcontactforthirdparty))
|
||||
{
|
||||
?>
|
||||
?>
|
||||
|
||||
<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']; ?>" />
|
||||
@ -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";
|
||||
|
||||
|
||||
@ -30,168 +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
|
||||
$sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
|
||||
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail']))
|
||||
{
|
||||
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();
|
||||
@ -199,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -142,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
|
||||
@ -217,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']);
|
||||
@ -231,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';
|
||||
@ -379,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();
|
||||
@ -594,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
|
||||
}
|
||||
@ -625,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?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.'">';
|
||||
@ -644,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");
|
||||
@ -750,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)
|
||||
{
|
||||
@ -808,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>';
|
||||
}
|
||||
|
||||
|
||||
@ -61,268 +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
|
||||
$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>';
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
$qualified = true;
|
||||
if (empty($enabled) || $enabled == 2) $qualified = false;
|
||||
if (empty($perms)) $qualified = false;
|
||||
if ($qualified) $message_admin .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
|
||||
}
|
||||
}
|
||||
$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 .= '</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>';
|
||||
$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>';
|
||||
|
||||
$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);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
// 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');
|
||||
//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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -336,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();
|
||||
@ -350,31 +350,31 @@ llxHeaderTicket($langs->trans("CreateTicket"), "", 0, 0, $arrayofjs, $arrayofcss
|
||||
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>';
|
||||
|
||||
@ -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);
|
||||
@ -227,178 +227,178 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
|
||||
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>";
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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.")";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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&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&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 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)));
|
||||
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="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>';
|
||||
}
|
||||
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
@ -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">';
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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,107 +99,107 @@ if ($rss) {
|
||||
|
||||
$website->fetch('', $websitekey);
|
||||
|
||||
$MAXNEWS = 20;
|
||||
$arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters);
|
||||
$MAXNEWS = 20;
|
||||
$arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters);
|
||||
$eventarray = array();
|
||||
foreach($arrayofblogs as $blog) {
|
||||
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)
|
||||
{
|
||||
$langs->load("other");
|
||||
$title = $desc = $langs->transnoentities('LatestBlogPosts');
|
||||
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, '', $website->virtualhost.'/wrapper.php?rss=1');
|
||||
// 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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user