Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
fb8ecf10d9
@ -34,6 +34,7 @@
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
|
||||
@ -56,6 +57,7 @@ class Categorie extends CommonObject
|
||||
const TYPE_WAREHOUSE = 'warehouse';
|
||||
const TYPE_ACTIONCOMM = 'actioncomm';
|
||||
const TYPE_WEBSITE_PAGE = 'website_page';
|
||||
const TYPE_TICKET = 'ticket';
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
@ -78,7 +80,8 @@ class Categorie extends CommonObject
|
||||
'bank_line' => 8,
|
||||
'warehouse' => 9,
|
||||
'actioncomm' => 10,
|
||||
'website_page' => 11
|
||||
'website_page' => 11,
|
||||
'ticket' => 12
|
||||
);
|
||||
|
||||
/**
|
||||
@ -98,7 +101,8 @@ class Categorie extends CommonObject
|
||||
8 => 'bank_line',
|
||||
9 => 'warehouse',
|
||||
10 => 'actioncomm',
|
||||
11 => 'website_page'
|
||||
11 => 'website_page',
|
||||
12 => 'ticket'
|
||||
);
|
||||
|
||||
/**
|
||||
@ -141,7 +145,8 @@ class Categorie extends CommonObject
|
||||
'project' => 'Project',
|
||||
'warehouse'=> 'Entrepot',
|
||||
'actioncomm' => 'ActionComm',
|
||||
'website_page' => 'WebsitePage'
|
||||
'website_page' => 'WebsitePage',
|
||||
'ticket' => 'Ticket'
|
||||
);
|
||||
|
||||
/**
|
||||
@ -234,6 +239,8 @@ class Categorie extends CommonObject
|
||||
* @see Categorie::TYPE_WAREHOUSE
|
||||
* @see Categorie::TYPE_ACTIONCOMM
|
||||
* @see Categorie::TYPE_WEBSITE_PAGE
|
||||
* @see Categorie::TYPE_TICKET
|
||||
|
||||
*/
|
||||
public $type;
|
||||
|
||||
|
||||
@ -497,6 +497,50 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draft interventionals
|
||||
*/
|
||||
if (!empty($conf->ficheinter->enabled)) {
|
||||
$sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
|
||||
$sql .= " AND f.fk_soc = s.rowid";
|
||||
$sql .= " AND f.fk_statut = 0";
|
||||
if ($socid) {
|
||||
$sql .= " AND f.fk_soc = ".((int) $socid);
|
||||
}
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
|
||||
$langs->load("fichinter");
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num) {
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
print "<a href=\"card.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowFichinter"), "intervention").' '.$obj->ref."</a></td>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($obj->name, 24).'</a></td></tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print "</table></div>";
|
||||
}
|
||||
}
|
||||
|
||||
print '</div><div class="fichetwothirdright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
|
||||
|
||||
@ -4454,7 +4454,6 @@ class Form
|
||||
*/
|
||||
public function selectEstablishments($selected = '', $htmlname = 'entity', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
$langs->load("admin");
|
||||
@ -6582,6 +6581,213 @@ class Form
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of tickets in Ajax if Ajax activated or go to selectTicketsList
|
||||
*
|
||||
* @param int $selected Preselected tickets
|
||||
* @param string $htmlname Name of HTML select field (must be unique in page).
|
||||
* @param string $filtertype To add a filter
|
||||
* @param int $limit Limit on number of returned lines
|
||||
* @param int $status Ticket status
|
||||
* @param string $selected_input_value Value of preselected input text (for use with ajax)
|
||||
* @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after)
|
||||
* @param array $ajaxoptions Options for ajax_autocompleter
|
||||
* @param int $socid Thirdparty Id (to get also price dedicated to this customer)
|
||||
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @param string $morecss Add more css on select
|
||||
* @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...])
|
||||
* @param string $nooutput No print, return the output into a string
|
||||
* @return void|string
|
||||
*/
|
||||
public function selectTickets($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$out = '';
|
||||
|
||||
// check parameters
|
||||
if (is_null($ajaxoptions)) $ajaxoptions = array();
|
||||
|
||||
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
|
||||
$placeholder = '';
|
||||
|
||||
if ($selected && empty($selected_input_value)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
|
||||
$tickettmpselect = new Ticket($this->db);
|
||||
$tickettmpselect->fetch($selected);
|
||||
$selected_input_value = $tickettmpselect->ref;
|
||||
unset($tickettmpselect);
|
||||
}
|
||||
|
||||
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/ticket/ajax/tickets.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
|
||||
|
||||
if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel").' : ';
|
||||
elseif ($hidelabel > 1) {
|
||||
$placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
|
||||
if ($hidelabel == 2) {
|
||||
$out .= img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
}
|
||||
$out .= '<input type="text" class="minwidth100" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
|
||||
if ($hidelabel == 3) {
|
||||
$out .= img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
} else {
|
||||
$out .= $this->selectTicketsList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
|
||||
}
|
||||
|
||||
if (empty($nooutput)) print $out;
|
||||
else return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return list of tickets.
|
||||
* Called by selectTickets.
|
||||
*
|
||||
* @param int $selected Preselected ticket
|
||||
* @param string $htmlname Name of select html
|
||||
* @param string $filtertype Filter on ticket type
|
||||
* @param int $limit Limit on number of returned lines
|
||||
* @param string $filterkey Filter on product
|
||||
* @param int $status Ticket status
|
||||
* @param int $outputmode 0=HTML select string, 1=Array
|
||||
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @param string $morecss Add more css on select
|
||||
* @return array Array of keys for json
|
||||
*/
|
||||
public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
|
||||
{
|
||||
global $langs, $conf, $user, $db;
|
||||
|
||||
$out = '';
|
||||
$outarray = array();
|
||||
|
||||
$selectFields = " p.rowid, p.ref, p.message";
|
||||
|
||||
$sql = "SELECT ";
|
||||
$sql .= $selectFields;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as p";
|
||||
$sql .= ' WHERE p.entity IN ('.getEntity('ticket').')';
|
||||
|
||||
// Add criteria on ref/label
|
||||
if ($filterkey != '') {
|
||||
$sql .= ' AND (';
|
||||
$prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
|
||||
// For natural search
|
||||
$scrit = explode(' ', $filterkey);
|
||||
$i = 0;
|
||||
if (count($scrit) > 1) $sql .= "(";
|
||||
foreach ($scrit as $crit) {
|
||||
if ($i > 0) $sql .= " AND ";
|
||||
$sql .= "(p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'";
|
||||
$sql .= ")";
|
||||
$i++;
|
||||
}
|
||||
if (count($scrit) > 1) $sql .= ")";
|
||||
$sql .= ')';
|
||||
}
|
||||
|
||||
$sql .= $this->db->plimit($limit, 0);
|
||||
|
||||
// Build output string
|
||||
dol_syslog(get_class($this)."::selectTicketsList search tickets", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
|
||||
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
$events = null;
|
||||
|
||||
if (!$forcecombo) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
$out .= ajax_combobox($htmlname, $events, $conf->global->TICKET_USE_SEARCH_TO_SELECT);
|
||||
}
|
||||
|
||||
$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||
|
||||
$textifempty = '';
|
||||
// Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
|
||||
//if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
|
||||
if (!empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
|
||||
if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
|
||||
else $textifempty .= $langs->trans("All");
|
||||
} else {
|
||||
if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
|
||||
}
|
||||
if ($showempty) $out .= '<option value="0" selected>'.$textifempty.'</option>';
|
||||
|
||||
$i = 0;
|
||||
while ($num && $i < $num) {
|
||||
$opt = '';
|
||||
$optJson = array();
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$this->constructTicketListOption($objp, $opt, $optJson, $selected, $filterkey);
|
||||
// Add new entry
|
||||
// "key" value of json key array is used by jQuery automatically as selected value
|
||||
// "label" value of json key array is used by jQuery automatically as text for combo box
|
||||
$out .= $opt;
|
||||
array_push($outarray, $optJson);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$out .= '</select>';
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
if (empty($outputmode)) return $out;
|
||||
return $outarray;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* constructTicketListOption.
|
||||
* This define value for &$opt and &$optJson.
|
||||
*
|
||||
* @param resource $objp Result set of fetch
|
||||
* @param string $opt Option (var used for returned value in string option format)
|
||||
* @param string $optJson Option (var used for returned value in json format)
|
||||
* @param string $selected Preselected value
|
||||
* @param string $filterkey Filter key to highlight
|
||||
* @return void
|
||||
*/
|
||||
protected function constructTicketListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
|
||||
{
|
||||
global $langs, $conf, $user, $db;
|
||||
|
||||
$outkey = '';
|
||||
$outval = '';
|
||||
$outref = '';
|
||||
$outlabel = '';
|
||||
$outtype = '';
|
||||
|
||||
$label = $objp->label;
|
||||
|
||||
$outkey = $objp->rowid;
|
||||
$outref = $objp->ref;
|
||||
$outlabel = $objp->label;
|
||||
$outtype = $objp->fk_product_type;
|
||||
|
||||
$opt = '<option value="'.$objp->rowid.'"';
|
||||
$opt .= ($objp->rowid == $selected) ? ' selected' : '';
|
||||
$opt .= '>';
|
||||
$opt .= $objp->ref;
|
||||
$objRef = $objp->ref;
|
||||
if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
|
||||
$outval .= $objRef;
|
||||
|
||||
$opt .= "</option>\n";
|
||||
$optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtypem);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generic method to select a component from a combo list.
|
||||
|
||||
@ -272,6 +272,15 @@ class FormTicket
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
//Categories
|
||||
if ($conf->categorie->enabled) {
|
||||
// Categories
|
||||
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET, '', 'parent', 64, 0, 1);
|
||||
print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Attached files
|
||||
if (!empty($this->withfile)) {
|
||||
// Define list of attached files
|
||||
@ -701,7 +710,6 @@ class FormTicket
|
||||
$stringtoprint .= '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'_select" class="maxwidth500 minwidth400">';
|
||||
$stringtoprint .= '<input type="hidden" name="'.$htmlname.'_child_id" id="'.$htmlname.'_select_child_id" class="maxwidth500 minwidth400">';
|
||||
}
|
||||
$stringtoprint .= '<input type="submit" value="Envoyer le formulaire">';
|
||||
$stringtoprint .= '</select> ';
|
||||
|
||||
$levelid = 1;
|
||||
|
||||
@ -263,6 +263,8 @@ print '$( document ).ready(function() {
|
||||
var confirmContent = $(this).attr(\'data-confirm-content\');
|
||||
var confirmActionBtnLabel = $(this).attr(\'data-confirm-action-btn-label\');
|
||||
var confirmCancelBtnLabel = $(this).attr(\'data-confirm-cancel-btn-label\');
|
||||
var confirmModal = $(this).attr(\'data-confirm-modal\');
|
||||
if(confirmModal == undefined){ confirmModal = false; }
|
||||
|
||||
var confirmId = \'confirm-dialog-box\';
|
||||
if($(this).attr(\'id\') != undefined){ var confirmId = confirmId + "-" + $(this).attr(\'id\'); }
|
||||
@ -277,8 +279,9 @@ print '$( document ).ready(function() {
|
||||
|
||||
$confirmBox.dialog({
|
||||
autoOpen: true,
|
||||
modal: false,
|
||||
modal: confirmModal,
|
||||
//width: Math.min($( window ).width() - 50, 1700),
|
||||
width: \'auto\',
|
||||
dialogClass: \'confirm-dialog-box\',
|
||||
buttons: [
|
||||
{
|
||||
@ -297,11 +300,11 @@ print '$( document ).ready(function() {
|
||||
}
|
||||
],
|
||||
close: function( event, ui ) {
|
||||
$(\'#\'+confirmBox).remove();
|
||||
},
|
||||
$(\'#\'+confirmBox).remove();
|
||||
},
|
||||
open: function( event, ui ) {
|
||||
$confirmBox.html(confirmContent);
|
||||
}
|
||||
$confirmBox.html(confirmContent);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -9770,7 +9770,23 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
|
||||
* @param string $url the url for link
|
||||
* @param string $id attribute id of button
|
||||
* @param int $userRight user action right
|
||||
* @param array $params various params for future : recommended rather than adding more function arguments
|
||||
* // phpcs:disable
|
||||
* @param array $params = [ // Various params for future : recommended rather than adding more function arguments
|
||||
* 'attr' => [ // to add or override button attributes
|
||||
* 'xxxxx' => '', // your xxxxx attribute you want
|
||||
* 'class' => '', // to add more css class to the button class attribute
|
||||
* 'classOverride' => '' // to replace class attribute of the button
|
||||
* ],
|
||||
* 'confirm' => [
|
||||
* 'url' => 'http://', // Overide Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm.
|
||||
* 'title' => '', // Overide title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key
|
||||
* 'action-btn-label' => '', // Overide label of action button, if empty default label use "Confirm" lang key
|
||||
* 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key
|
||||
* 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key
|
||||
* 'modal' => true, // true|false to display dialog as a modal (with dark background)
|
||||
* ],
|
||||
* ]
|
||||
* // phpcs:enable
|
||||
* @return string html button
|
||||
*/
|
||||
function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array())
|
||||
@ -9818,7 +9834,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
|
||||
}
|
||||
|
||||
// Js Confirm button
|
||||
if (!empty($params['confirm'])) {
|
||||
if ($userRight && !empty($params['confirm'])) {
|
||||
if (!is_array($params['confirm'])) {
|
||||
$params['confirm'] = array(
|
||||
'url' => $url . (strpos($url, '?') > 0 ? '&' : '?') . 'confirm=yes'
|
||||
@ -9829,8 +9845,11 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
|
||||
$attr['data-confirm-url'] = $params['confirm']['url'];
|
||||
$attr['data-confirm-title'] = !empty($params['confirm']['title']) ? $params['confirm']['title'] : $langs->trans('ConfirmBtnCommonTitle', $label);
|
||||
$attr['data-confirm-content'] = !empty($params['confirm']['content']) ? $params['confirm']['content'] : $langs->trans('ConfirmBtnCommonContent', $label);
|
||||
$attr['data-confirm-content'] = preg_replace("/\r|\n/", "", $attr['data-confirm-content']);
|
||||
$attr['data-confirm-action-btn-label'] = !empty($params['confirm']['action-btn-label']) ? $params['confirm']['action-btn-label'] : $langs->trans('Confirm');
|
||||
$attr['data-confirm-cancel-btn-label'] = !empty($params['confirm']['cancel-btn-label']) ? $params['confirm']['cancel-btn-label'] : $langs->trans('CloseDialog');
|
||||
$attr['data-confirm-modal'] = !empty($params['confirm']['modal']) ? $params['confirm']['modal'] : true;
|
||||
|
||||
$attr['class'].= ' butActionConfirm';
|
||||
}
|
||||
|
||||
|
||||
@ -283,6 +283,19 @@ class modTicket extends DolibarrModules
|
||||
'target' => '',
|
||||
'user' => 0);
|
||||
$r++;
|
||||
|
||||
$this->menu[$r] = array('fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket',
|
||||
'type' => 'left',
|
||||
'titre' => 'Categories',
|
||||
'mainmenu' => 'ticket',
|
||||
'url' => '/categories/index.php?type=12',
|
||||
'langs' => 'ticket',
|
||||
'position' => 107,
|
||||
'enabled' => '$conf->categorie->enabled',
|
||||
'perms' => '$user->rights->ticket->read',
|
||||
'target' => '',
|
||||
'user' => 0);
|
||||
$r++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -813,6 +813,111 @@ if ($ispaymentok) {
|
||||
$postactionmessages[] = 'Invoice paid '.$tmptag['INV'].' was not found';
|
||||
$ispostactionok = -1;
|
||||
}
|
||||
} elseif (array_key_exists('ORD', $tmptag) && $tmptag['ORD'] > 0) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
|
||||
$object = new Commande($db);
|
||||
$result = $object->fetch($tmptag['ORD']);
|
||||
if ($result) {
|
||||
$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
|
||||
|
||||
$paymentTypeId = 0;
|
||||
if ($paymentmethod == 'paybox') $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
|
||||
if ($paymentmethod == 'paypal') $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
|
||||
if ($paymentmethod == 'stripe') $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
|
||||
if (empty($paymentTypeId)) {
|
||||
$paymentType = $_SESSION["paymentType"];
|
||||
if (empty($paymentType)) $paymentType = 'CB';
|
||||
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
|
||||
}
|
||||
|
||||
$currencyCodeType = $_SESSION['currencyCodeType'];
|
||||
|
||||
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
|
||||
if (!empty($conf->facture->enabled)) {
|
||||
if (!empty($FinalPaymentAmt) && $paymentTypeId > 0 ) {
|
||||
include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
||||
$invoice = new Facture($db);
|
||||
$result = $invoice->createFromOrder($object, $user);
|
||||
if ($result > 0) {
|
||||
$object->classifyBilled($user);
|
||||
$invoice->validate($user);
|
||||
// Creation of payment line
|
||||
include_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
|
||||
$paiement = new Paiement($db);
|
||||
$paiement->datepaye = $now;
|
||||
if ($currencyCodeType == $conf->currency) {
|
||||
$paiement->amounts = array($invoice->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id
|
||||
} else {
|
||||
$paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt); // Array with all payments dispatching
|
||||
|
||||
$postactionmessages[] = 'Payment was done in a different currency that currency expected of company';
|
||||
$ispostactionok = -1;
|
||||
$error++;
|
||||
}
|
||||
$paiement->paiementid = $paymentTypeId;
|
||||
$paiement->num_payment = '';
|
||||
$paiement->note_public = 'Online payment ' . dol_print_date($now, 'standard') . ' from ' . $ipaddress;
|
||||
$paiement->ext_payment_id = $TRANSACTIONID;
|
||||
$paiement->ext_payment_site = '';
|
||||
|
||||
if (!$error) {
|
||||
$paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents
|
||||
if ($paiement_id < 0) {
|
||||
$postactionmessages[] = $paiement->error . ' ' . join("<br>\n", $paiement->errors);
|
||||
$ispostactionok = -1;
|
||||
$error++;
|
||||
} else {
|
||||
$postactionmessages[] = 'Payment created';
|
||||
$ispostactionok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->banque->enabled)) {
|
||||
$bankaccountid = 0;
|
||||
if ($paymentmethod == 'paybox') $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
|
||||
elseif ($paymentmethod == 'paypal') $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
|
||||
elseif ($paymentmethod == 'stripe') $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
|
||||
|
||||
if ($bankaccountid > 0) {
|
||||
$label = '(CustomerInvoicePayment)';
|
||||
if ($object->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
|
||||
$result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', '');
|
||||
if ($result < 0) {
|
||||
$postactionmessages[] = $paiement->error . ' ' . join("<br>\n", $paiement->errors);
|
||||
$ispostactionok = -1;
|
||||
$error++;
|
||||
} else {
|
||||
$postactionmessages[] = 'Bank transaction of payment created';
|
||||
$ispostactionok = 1;
|
||||
}
|
||||
} else {
|
||||
$postactionmessages[] = 'Setup of bank account to use in module ' . $paymentmethod . ' was not set. No way to record the payment.';
|
||||
$ispostactionok = -1;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
} else {
|
||||
$postactionmessages[] = 'Failed to create invoice form order ' . $tmptag['ORD'] . '.';
|
||||
$ispostactionok = -1;
|
||||
}
|
||||
} else {
|
||||
$postactionmessages[] = 'Failed to get a valid value for "amount paid" (' . $FinalPaymentAmt . ') or "payment type" (' . $paymentType . ') to record the payment of order ' . $tmptag['ORD'] . '. May be payment was already recorded.';
|
||||
$ispostactionok = -1;
|
||||
}
|
||||
} else {
|
||||
$postactionmessages[] = 'Invoice module is not enable';
|
||||
$ispostactionok = -1;
|
||||
}
|
||||
} else {
|
||||
$postactionmessages[] = 'Order paid ' . $tmptag['ORD'] . ' was not found';
|
||||
$ispostactionok = -1;
|
||||
}
|
||||
} elseif (array_key_exists('DON', $tmptag) && $tmptag['DON'] > 0) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
$don = new Don($db);
|
||||
|
||||
@ -20,7 +20,9 @@ if (!defined('NOREQUIREAJAX')) {
|
||||
if (!defined('NOSESSION')) {
|
||||
define('NOSESSION', '1');
|
||||
}
|
||||
|
||||
if (!defined('NOREQUIREMENU')) {
|
||||
define('NOREQUIREMENU', '1');
|
||||
}
|
||||
session_cache_limiter('public');
|
||||
|
||||
require_once '../../main.inc.php';
|
||||
@ -30,19 +32,9 @@ if ($dolibarr_main_prod) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
llxHeader('', 'Documentation and examples for theme');
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="Documentation and examples for theme.">
|
||||
|
||||
<link href="<?php echo DOL_URL_ROOT ?>/theme/eldy/style.css.php" rel="stylesheet">
|
||||
</head>
|
||||
<body class="docpage" style="padding: 20px;">
|
||||
|
||||
<main role="main" >
|
||||
<h1 class="bd-title" id="content">Badges</h1>
|
||||
<p class="bd-lead">Documentation and examples for badges, our small count and labeling component.</p>
|
||||
|
||||
@ -342,5 +334,4 @@ if ($dolibarr_main_prod) {
|
||||
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php llxFooter();
|
||||
|
||||
196
htdocs/public/test/buttons.php
Normal file
196
htdocs/public/test/buttons.php
Normal file
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
if (!defined('NOREQUIRESOC')) {
|
||||
define('NOREQUIRESOC', '1');
|
||||
}
|
||||
if (!defined('NOCSRFCHECK')) {
|
||||
define('NOCSRFCHECK', 1);
|
||||
}
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', 1);
|
||||
}
|
||||
if (!defined('NOLOGIN')) {
|
||||
define('NOLOGIN', 1); // File must be accessed by logon page so without login
|
||||
}
|
||||
if (!defined('NOREQUIREHTML')) {
|
||||
define('NOREQUIREHTML', 1);
|
||||
}
|
||||
if (!defined('NOREQUIREAJAX')) {
|
||||
define('NOREQUIREAJAX', '1');
|
||||
}
|
||||
if (!defined('NOSESSION')) {
|
||||
define('NOSESSION', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREMENU')) {
|
||||
define('NOREQUIREMENU', '1');
|
||||
}
|
||||
session_cache_limiter('public');
|
||||
|
||||
require_once '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||||
|
||||
if ($dolibarr_main_prod) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
llxHeader('', 'Documentation and examples for theme');
|
||||
?>
|
||||
<main role="main" >
|
||||
<h1 class="bd-title" id="content">Button for action</h1>
|
||||
<p class="bd-lead">Documentation and examples for buttons.</p>
|
||||
|
||||
<h2 id="example01">Example of simple usage</h2>
|
||||
|
||||
<p>Buttons for user allowed to click.</p>
|
||||
|
||||
<div class="bd-example">
|
||||
<?php
|
||||
$n = 1;
|
||||
$label = 'My action label used for accessibility visually for impaired people';
|
||||
$html = '<span class="fa fa-clone" ></span> My default action';
|
||||
$actionType = 'default';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = '#'.$id;
|
||||
$userRight = 1;
|
||||
$params = array();
|
||||
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
|
||||
|
||||
|
||||
$html = '<span class="fa fa-clone" ></span> My delete action';
|
||||
$actionType = 'delete';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
|
||||
|
||||
|
||||
$html = '<span class="fa fa-clone" ></span> My danger action';
|
||||
$actionType = 'danger';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<p>Buttons for user <strong>NOT</strong> allowed to click.</p>
|
||||
|
||||
<div class="bd-example">
|
||||
<?php
|
||||
$label = 'My action label used for accessibility visually for impaired people';
|
||||
$html = '<span class="fa fa-clone" ></span> My default action';
|
||||
$actionType = 'default';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = '#'.$id;
|
||||
$userRight = 0;
|
||||
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
|
||||
|
||||
|
||||
$html = '<span class="fa fa-clone" ></span> My delete action';
|
||||
$actionType = 'delete';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
|
||||
|
||||
|
||||
$html = '<span class="fa fa-clone" ></span> My danger action';
|
||||
$actionType = 'danger';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight);
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="example01">Example of confirm dialog</h2>
|
||||
|
||||
<p>Buttons for user allowed to click.</p>
|
||||
|
||||
<div class="bd-example">
|
||||
<?php
|
||||
$label = 'My action label used for accessibility visually for impaired people';
|
||||
$html = '<span class="fa fa-clone" ></span> My default action';
|
||||
$actionType = 'default';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = '#'.$id;
|
||||
$userRight = 1;
|
||||
$params = array(
|
||||
'confirm' => true
|
||||
);
|
||||
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
|
||||
|
||||
|
||||
$html = '<span class="fa fa-clone" ></span> My delete action';
|
||||
$actionType = 'delete';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
|
||||
|
||||
$params = array(
|
||||
'confirm' => array(
|
||||
'url' => 'your confirm action url',
|
||||
'title' => 'Your title to display',
|
||||
'action-btn-label' => 'Your confirm label',
|
||||
'cancel-btn-label' => 'Your cancel label',
|
||||
'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>'
|
||||
)
|
||||
);
|
||||
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<p>Buttons for user <strong>NOT</strong> allowed to click.</p>
|
||||
|
||||
<div class="bd-example">
|
||||
<?php
|
||||
$label = 'My action label used for accessibility visually for impaired people';
|
||||
$html = '<span class="fa fa-clone" ></span> My default action';
|
||||
$actionType = 'default';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = '#'.$id;
|
||||
$userRight = 0;
|
||||
$params = array(
|
||||
'confirm' => true
|
||||
);
|
||||
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
|
||||
|
||||
|
||||
$html = '<span class="fa fa-clone" ></span> My delete action';
|
||||
$actionType = 'delete';
|
||||
$n++;
|
||||
$id = 'mybuttonid'.$n;
|
||||
$url = $_SERVER['PHP_SELF'] . '?token='.newToken().'#'.$id;
|
||||
|
||||
$params = array(
|
||||
'confirm' => array(
|
||||
'url' => 'your confirm action url',
|
||||
'title' => 'Your title to display',
|
||||
'action-btn-label' => 'Your confirm label',
|
||||
'cancel-btn-label' => 'Your cancel label',
|
||||
'content' => 'Content to display with <strong>HTML</strong> compatible <ul><li>test 01</li><li>test 02</li><li>test 03</li></ul>'
|
||||
)
|
||||
);
|
||||
|
||||
print dolGetButtonAction($label, $html, $actionType, $url, $id, $userRight, $params);
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
</main>
|
||||
|
||||
<?php llxFooter();
|
||||
@ -2499,6 +2499,51 @@ class Ticket extends CommonObject
|
||||
return array('listofpaths'=>$listofpaths, 'listofnames'=>$listofnames, 'listofmimes'=>$mimetype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets object to supplied categories.
|
||||
*
|
||||
* Deletes object from existing categories not supplied.
|
||||
* Adds it to non existing supplied categories.
|
||||
* Existing categories are left untouch.
|
||||
*
|
||||
* @param int[]|int $categories Category or categories IDs
|
||||
* @return void
|
||||
*/
|
||||
public function setCategories($categories)
|
||||
{
|
||||
// Handle single category
|
||||
if (!is_array($categories)) {
|
||||
$categories = array($categories);
|
||||
}
|
||||
|
||||
// Get current categories
|
||||
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$c = new Categorie($this->db);
|
||||
$existing = $c->containing($this->id, Categorie::TYPE_TICKET, 'id');
|
||||
|
||||
// Diff
|
||||
if (is_array($existing)) {
|
||||
$to_del = array_diff($existing, $categories);
|
||||
$to_add = array_diff($categories, $existing);
|
||||
} else {
|
||||
$to_del = array(); // Nothing to delete
|
||||
$to_add = $categories;
|
||||
}
|
||||
|
||||
// Process
|
||||
foreach ($to_del as $del) {
|
||||
if ($c->fetch($del) > 0) {
|
||||
$c->del_type($this, Categorie::TYPE_TICKET);
|
||||
}
|
||||
}
|
||||
foreach ($to_add as $add) {
|
||||
if ($c->fetch($add) > 0) {
|
||||
$c->add_type($this, Categorie::TYPE_TICKET);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new message on a ticket (private/public area). Can also send it be email if GETPOST('send_email', 'int') is set.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user