mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
4bae510cfc
|
|
@ -425,7 +425,7 @@ class Members extends DolibarrApi
|
|||
}
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$member->array_options[$index] = $val;
|
||||
$member->array_options[$index] = $this->_checkValForAPI($field, $val, $member);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
336
htdocs/adherents/class/api_memberstypes.class.php
Normal file
336
htdocs/adherents/class/api_memberstypes.class.php
Normal file
|
|
@ -0,0 +1,336 @@
|
|||
<?php
|
||||
/* Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
||||
|
||||
/**
|
||||
* API class for members types
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class MembersTypes extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
public static $FIELDS = array(
|
||||
'label',
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of a member type object
|
||||
*
|
||||
* Return an array with member type information
|
||||
*
|
||||
* @param int $id ID of member type
|
||||
* @return Object Object with cleaned properties
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($membertype);
|
||||
}
|
||||
|
||||
/**
|
||||
* List members types
|
||||
*
|
||||
* Get a list of members types
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')"
|
||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||
* @return array Array of member type objects
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type AS t LEFT JOIN ".MAIN_DB_PREFIX."adherent_type_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('member_type').')';
|
||||
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
$errormessage = '';
|
||||
$sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
|
||||
if ($errormessage) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$membertype = new AdherentType($this->db);
|
||||
if ($membertype->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($membertype), $properties);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create member type object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of member type
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
$membertype = new AdherentType($this->db);
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field === 'caller') {
|
||||
// Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
|
||||
$membertype->context['caller'] = $request_data['caller'];
|
||||
continue;
|
||||
}
|
||||
|
||||
$membertype->$field = $value;
|
||||
}
|
||||
if ($membertype->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors));
|
||||
}
|
||||
return $membertype->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update member type
|
||||
*
|
||||
* @param int $id ID of member type to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') {
|
||||
continue;
|
||||
}
|
||||
if ($field === 'caller') {
|
||||
// Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
|
||||
$membertype->context['caller'] = $request_data['caller'];
|
||||
continue;
|
||||
}
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$membertype->array_options[$index] = $this->_checkValForAPI($field, $val, $membertype);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Process the status separately because it must be updated using
|
||||
// the validate(), resiliate() and exclude() methods of the class AdherentType.
|
||||
$membertype->$field = $this->_checkValForAPI($field, $value, $membertype);
|
||||
}
|
||||
|
||||
// If there is no error, update() returns the number of affected rows
|
||||
// so if the update is a no op, the return value is zero.
|
||||
if ($membertype->update(DolibarrApiAccess::$user) >= 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, 'Error when updating member type: '.$membertype->error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete member type
|
||||
*
|
||||
* @param int $id member type ID
|
||||
* @return array
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
$res = $membertype->delete(DolibarrApiAccess::$user);
|
||||
if ($res < 0) {
|
||||
throw new RestException(500, "Can't delete, error occurs");
|
||||
} elseif ($res == 0) {
|
||||
throw new RestException(409, "Can't delete, that product is probably used");
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'Member type deleted'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$membertype = array();
|
||||
foreach (MembersTypes::$FIELDS as $field) {
|
||||
if (!isset($data[$field])) {
|
||||
throw new RestException(400, "$field field missing");
|
||||
}
|
||||
$membertype[$field] = $data[$field];
|
||||
}
|
||||
return $membertype;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param Object $object Object to clean
|
||||
* @return Object Object with cleaned properties
|
||||
*/
|
||||
protected function _cleanObjectDatas($object)
|
||||
{
|
||||
// phpcs:enable
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
unset($object->array_options);
|
||||
unset($object->linkedObjectsIds);
|
||||
unset($object->context);
|
||||
unset($object->canvas);
|
||||
unset($object->fk_project);
|
||||
unset($object->contact);
|
||||
unset($object->contact_id);
|
||||
unset($object->thirdparty);
|
||||
unset($object->user);
|
||||
unset($object->origin);
|
||||
unset($object->origin_id);
|
||||
unset($object->ref_ext);
|
||||
unset($object->country);
|
||||
unset($object->country_id);
|
||||
unset($object->country_code);
|
||||
unset($object->barcode_type);
|
||||
unset($object->barcode_type_code);
|
||||
unset($object->barcode_type_label);
|
||||
unset($object->barcode_type_coder);
|
||||
unset($object->mode_reglement_id);
|
||||
unset($object->cond_reglement_id);
|
||||
unset($object->cond_reglement);
|
||||
unset($object->fk_delivery_address);
|
||||
unset($object->shipping_method_id);
|
||||
unset($object->model_pdf);
|
||||
unset($object->fk_account);
|
||||
unset($object->note_public);
|
||||
unset($object->note_private);
|
||||
unset($object->fk_incoterms);
|
||||
unset($object->label_incoterms);
|
||||
unset($object->location_incoterms);
|
||||
unset($object->name);
|
||||
unset($object->lastname);
|
||||
unset($object->firstname);
|
||||
unset($object->civility_id);
|
||||
unset($object->total_ht);
|
||||
unset($object->total_tva);
|
||||
unset($object->total_localtax1);
|
||||
unset($object->total_localtax2);
|
||||
unset($object->total_ttc);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
|
@ -234,6 +234,12 @@ class Subscriptions extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$subscription->array_options[$index] = $this->_checkValForAPI($field, $val, $subscription);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$subscription->$field = $this->_checkValForAPI($field, $value, $subscription);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2367,7 +2367,10 @@ if ($id > 0) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($value == 'element') {
|
||||
// Management of several special cases and exceptions
|
||||
if ($value == 'code' && $id == DICT_PRODUCT_NATURE) {
|
||||
$valuetoshow = (int) $valuetoshow;
|
||||
} elseif ($value == 'element') {
|
||||
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
|
||||
} elseif ($value == 'source') {
|
||||
$valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
|
||||
|
|
@ -2543,6 +2546,7 @@ if ($id > 0) {
|
|||
$valuetoshow = $TDurationTypes[$obj->{$value}];
|
||||
}
|
||||
}
|
||||
|
||||
$class .= ($class ? ' ' : '').'tddict';
|
||||
if ($value == 'name') {
|
||||
$class .= ' tdoverflowmax200';
|
||||
|
|
@ -2790,12 +2794,11 @@ function dictFieldList($fieldlist, $obj = null, $tabname = '', $context = '')
|
|||
print '</td>';
|
||||
} elseif ($value == 'department_buyer') {
|
||||
if ($context == 'edit') {
|
||||
print '<td>';
|
||||
print '<td class="nowraponall">';
|
||||
// show department buyer list
|
||||
$country_code = (!empty($obj->country_code) ? $obj->country_code : '');
|
||||
$department_buyer_id = (!empty($obj->department_buyer_id) ? (int) $obj->department_buyer_id : 0);
|
||||
if ($country_code != '') {
|
||||
print img_picto('', 'state', 'class="pictofixedwidth"');
|
||||
print $formcompany->select_state($department_buyer_id, $country_code, 'department_buyer_id', 'minwidth100 maxwidth150 maxwidthonsmartphone');
|
||||
}
|
||||
print '</td>';
|
||||
|
|
|
|||
|
|
@ -249,11 +249,10 @@ class Boms extends DolibarrApi
|
|||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->bom->array_options[$index] = $this->_checkValForAPI('extrafields', $val, $this->bom);
|
||||
$this->bom->array_options[$index] = $this->_checkValForAPI($field, $val, $this->bom);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->bom->$field = $this->_checkValForAPI($field, $value, $this->bom);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,6 +252,13 @@ class Categories extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->category->array_options[$index] = $this->_checkValForAPI($field, $val, $this->category);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->category->$field = $this->_checkValForAPI($field, $value, $this->category);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1883,7 +1883,7 @@ class ActionComm extends CommonObject
|
|||
$color = 'style="color: #'.$this->type_color.' !important;"';
|
||||
}
|
||||
if ($this->type_picto) {
|
||||
$imgpicto = img_picto($titlealt, $this->type_picto, '', 0, 0, 0, '', ($morecss ? ' '.$morecss : ''));
|
||||
$imgpicto = img_picto($titlealt.'rr', $this->type_picto, '', 0, 0, 0, '', ($morecss ? ' '.$morecss : ''));
|
||||
} else {
|
||||
if ($this->type_code == 'AC_RDV') {
|
||||
$imgpicto = img_picto($titlealt, 'meeting', $color, 0, 0, 0, '', ($morecss ? ' '.$morecss : ''));
|
||||
|
|
@ -1891,7 +1891,7 @@ class ActionComm extends CommonObject
|
|||
$imgpicto = img_picto($titlealt, 'object_phoning', $color, 0, 0, 0, '', ($morecss ? ' '.$morecss : ''));
|
||||
} elseif ($this->type_code == 'AC_FAX') {
|
||||
$imgpicto = img_picto($titlealt, 'object_phoning_fax', $color, 0, 0, 0, '', ($morecss ? ' '.$morecss : ''));
|
||||
} elseif ($this->type_code == 'AC_EMAIL' || $this->type_code == 'AC_EMAIL_IN' || (!empty($this->code) && preg_match('/_SENTBYMAIL/', $this->code))) {
|
||||
} elseif ($this->type_code == 'AC_EMAIL' || $this->type_code == 'AC_EMAIL_IN' || $this->type_code == 'AC_EMAILING' || (!empty($this->code) && preg_match('/_SENTBYMAIL/', $this->code))) {
|
||||
$imgpicto = img_picto($titlealt, 'object_email', $color, 0, 0, 0, '', ($morecss ? ' '.$morecss : ''));
|
||||
} elseif ($this->type_code == 'AC_INT') {
|
||||
$imgpicto = img_picto($titlealt, 'object_intervention', $color, 0, 0, 0, '', ($morecss ? ' '.$morecss : ''));
|
||||
|
|
|
|||
|
|
@ -287,6 +287,12 @@ class AgendaEvents extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->actioncomm->array_options[$index] = $this->_checkValForAPI($field, $val, $this->actioncomm);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$this->actioncomm->$field = $this->_checkValForAPI($field, $value, $this->actioncomm);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,11 +163,13 @@ class CActionComm
|
|||
global $langs, $conf, $user;
|
||||
$langs->load("commercial");
|
||||
|
||||
/*
|
||||
$actionstatic = new ActionComm($this->db);
|
||||
|
||||
$rep_id = array();
|
||||
$rep_code = array();
|
||||
$rep_all = array();
|
||||
*/
|
||||
|
||||
$sql = "SELECT id, code, libelle as label, module, type, color, picto";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
|
||||
|
|
|
|||
|
|
@ -348,6 +348,12 @@ class BankAccounts extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$account->array_options[$index] = $this->_checkValForAPI($field, $val, $account);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$account->$field = $this->_checkValForAPI($field, $value, $account);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3336,9 +3336,9 @@ if ($action == 'create') {
|
|||
$expesrc->fetch_optionals();
|
||||
$object->array_options = $expesrc->array_options;
|
||||
} else {
|
||||
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
|
||||
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
|
||||
$fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
|
||||
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : (!empty($cond_reglement_id) ? $cond_reglement_id : 0)));
|
||||
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : (!empty($mode_reglement_id) ? $mode_reglement_id : 0)));
|
||||
$fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : (!empty($fk_account) ? $fk_account : 0)));
|
||||
|
||||
if (isModEnabled('multicurrency')) {
|
||||
if (!empty($objectsrc->multicurrency_code)) {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,21 @@ class Ccountry extends CommonDict
|
|||
'label' => array('type' => 'varchar(250)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'position' => 15, 'notnull' => -1, 'showoncombobox' => 1)
|
||||
);
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $favorite;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $eec;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $numeric_code;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -150,7 +165,10 @@ class Ccountry extends CommonDict
|
|||
$sql .= " t.code,";
|
||||
$sql .= " t.code_iso,";
|
||||
$sql .= " t.label,";
|
||||
$sql .= " t.active";
|
||||
$sql .= " t.eec,";
|
||||
$sql .= " t.active,";
|
||||
$sql .= " t.favorite,";
|
||||
$sql .= " t.numeric_code";
|
||||
$sql .= " FROM ".$this->db->prefix()."c_country as t";
|
||||
if ($id) {
|
||||
$sql .= " WHERE t.rowid = ".((int) $id);
|
||||
|
|
@ -161,6 +179,7 @@ class Ccountry extends CommonDict
|
|||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
|
|
@ -172,6 +191,9 @@ class Ccountry extends CommonDict
|
|||
$this->code_iso = $obj->code_iso;
|
||||
$this->label = $obj->label;
|
||||
$this->active = $obj->active;
|
||||
$this->favorite = $obj->favorite;
|
||||
$this->eec = $obj->eec;
|
||||
$this->numeric_code = $obj->numeric_code;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
|
|
|
|||
|
|
@ -3040,11 +3040,6 @@ class Form
|
|||
$sql .= ' AND e.statut IN (' . $this->db->sanitize($this->db->escape(implode(',', $warehouseStatusArray))) . ')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0.
|
||||
}
|
||||
|
||||
// include search in supplier ref
|
||||
if (getDolGlobalString('MAIN_SEARCH_PRODUCT_BY_FOURN_REF')) {
|
||||
$sql .= " LEFT JOIN " . $this->db->prefix() . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
|
||||
}
|
||||
|
||||
//Price by customer
|
||||
if ((getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && !empty($socid)) {
|
||||
$sql .= " LEFT JOIN " . $this->db->prefix() . "product_customer_price as pcp ON pcp.fk_soc=" . ((int) $socid) . " AND pcp.fk_product=p.rowid";
|
||||
|
|
@ -3110,6 +3105,8 @@ class Form
|
|||
$sql .= $hookmanager->resPrint;
|
||||
// Add criteria on ref/label
|
||||
if ($filterkey != '') {
|
||||
$sqlSupplierSearch= '';
|
||||
|
||||
$sql .= ' AND (';
|
||||
$prefix = !getDolGlobalString('PRODUCT_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
|
||||
// For natural search
|
||||
|
|
@ -3135,8 +3132,11 @@ class Form
|
|||
$sql .= " OR pl.description LIKE '" . $this->db->escape($prefix . $crit) . "%'";
|
||||
}
|
||||
}
|
||||
|
||||
// include search in supplier ref
|
||||
if (getDolGlobalString('MAIN_SEARCH_PRODUCT_BY_FOURN_REF')) {
|
||||
$sql .= " OR pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%'";
|
||||
$sqlSupplierSearch .= !empty($sqlSupplierSearch) ? ' OR ':'';
|
||||
$sqlSupplierSearch .= " pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%'";
|
||||
}
|
||||
$sql .= ")";
|
||||
$i++;
|
||||
|
|
@ -3147,6 +3147,15 @@ class Form
|
|||
if (isModEnabled('barcode')) {
|
||||
$sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'";
|
||||
}
|
||||
|
||||
// include search in supplier ref
|
||||
if (getDolGlobalString('MAIN_SEARCH_PRODUCT_BY_FOURN_REF')) {
|
||||
$sql .= " OR EXISTS (SELECT pfp.fk_product FROM " . $this->db->prefix() . "product_fournisseur_price as pfp WHERE p.rowid = pfp.fk_product";
|
||||
$sql .= " AND (";
|
||||
$sql .= $sqlSupplierSearch;
|
||||
$sql .= "))";
|
||||
}
|
||||
|
||||
$sql .= ')';
|
||||
}
|
||||
if (count($warehouseStatusArray)) {
|
||||
|
|
|
|||
|
|
@ -1828,6 +1828,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
|
|||
$sql .= " a.percent as percent, 'action' as type,";
|
||||
$sql .= " a.fk_element, a.elementtype,";
|
||||
$sql .= " a.fk_contact,";
|
||||
$sql .= " a.code,";
|
||||
$sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,";
|
||||
$sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
|
||||
if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur'))) {
|
||||
|
|
@ -2025,6 +2026,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
|
|||
$sql .= $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
// Now add events of emailing module
|
||||
if (is_array($actioncode)) {
|
||||
foreach ($actioncode as $code) {
|
||||
$sql2 = addMailingEventTypeSQL($code, $objcon, $filterobj);
|
||||
|
|
@ -2106,6 +2108,9 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
|
|||
'firstname' => empty($obj->firstname) ? '' : $obj->firstname,
|
||||
'fk_element' => (int) $obj->fk_element,
|
||||
'elementtype' => $obj->elementtype,
|
||||
|
||||
'code' => $obj->code,
|
||||
|
||||
// Type of event
|
||||
'acode' => $obj->acode,
|
||||
'alabel' => $obj->alabel,
|
||||
|
|
@ -2121,6 +2126,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
|
|||
'dateend' => $db->jdate($obj->dp2),
|
||||
'note' => $obj->label,
|
||||
'percent' => (int) $obj->percent,
|
||||
|
||||
'code' => $obj->code,
|
||||
|
||||
// Type of event
|
||||
'acode' => $obj->acode,
|
||||
|
||||
'userid' => (int) $obj->user_id,
|
||||
|
|
@ -2257,11 +2266,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
|
|||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
|
||||
$caction = new CActionComm($db);
|
||||
$arraylist = $caction->liste_array(1, 'code', '', (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : 0), '', 1);
|
||||
$arraylist = $caction->liste_array(1, 'code', '', (getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 0 : 1), '', 1);
|
||||
|
||||
foreach ($histo as $key => $value) {
|
||||
$actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo
|
||||
|
||||
if (empty($actionstatic->code)) {
|
||||
$actionstatic->code = $histo[$key]['acode'];
|
||||
}
|
||||
$actionstatic->type_picto = $histo[$key]['apicto'] ?? '';
|
||||
$actionstatic->type_code = $histo[$key]['acode'];
|
||||
|
||||
|
|
@ -2333,25 +2345,38 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
|
|||
}
|
||||
$out .= '</td>';
|
||||
|
||||
// type_code // column "acode" in the sql = code in type of actioncomm, example: AC_OTH_AUTO, AC_EMAILING
|
||||
// code // columne code in the sql (not yet added), can be AC_CONTACT_SENTBYMAIL, ...
|
||||
|
||||
// Type
|
||||
$labeltype = $actionstatic->type_code;
|
||||
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
|
||||
$labeltype = 'AC_OTH';
|
||||
$labelOfTypeToShow = $actionstatic->type_code;
|
||||
//$typelabel = $actionstatic->type_label;
|
||||
$code = $actionstatic->code;
|
||||
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labelOfTypeToShow])) {
|
||||
$labelOfTypeToShow = 'AC_OTH';
|
||||
}
|
||||
if (!empty($actionstatic->code) && preg_match('/^TICKET_MSG/', $actionstatic->code)) {
|
||||
$labeltype = $langs->trans("Message");
|
||||
$labelOfTypeToShow = $langs->trans("Message");
|
||||
} else {
|
||||
if (!empty($arraylist[$labeltype])) {
|
||||
$labeltype = $arraylist[$labeltype];
|
||||
if (!empty($arraylist[$labelOfTypeToShow])) {
|
||||
$labelOfTypeToShow = $arraylist[$labelOfTypeToShow];
|
||||
} elseif ($actionstatic->type_code == 'AC_EMAILING') {
|
||||
$labelOfTypeToShow = $langs->trans("Emailing");
|
||||
}
|
||||
if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
|
||||
$labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code
|
||||
if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labelOfTypeToShow && !empty($arraylist[$actionstatic->code])) {
|
||||
$labelOfTypeToShow .= ' - '.$arraylist[$actionstatic->code]; // Show also detailed code
|
||||
}
|
||||
}
|
||||
$out .= '<td class="tdoverflowmax125" title="'.$labeltype.'">';
|
||||
|
||||
$labelOfTypeToShowLong = $labelOfTypeToShow;
|
||||
if ($actionstatic->type_code == 'AC_OTH_AUTO') {
|
||||
$labelOfTypeToShowLong .= ' (auto)';
|
||||
}
|
||||
|
||||
$out .= '<td class="tdoverflowmax125" title="'.$labelOfTypeToShowLong.'">';
|
||||
$out .= $actionstatic->getTypePicto();
|
||||
//if (empty($conf->dol_optimize_smallscreen)) {
|
||||
$out .= $labeltype;
|
||||
$out .= $labelOfTypeToShow;
|
||||
//}
|
||||
$out .= '</td>';
|
||||
|
||||
|
|
@ -2360,18 +2385,19 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr
|
|||
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') {
|
||||
$transcode = $langs->trans("Action".$histo[$key]['acode']);
|
||||
//$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']);
|
||||
$libelle = $histo[$key]['note'];
|
||||
$label = $histo[$key]['note'];
|
||||
$actionstatic->id = $histo[$key]['id'];
|
||||
$out .= ' title="'.dol_escape_htmltag($libelle).'">';
|
||||
$out .= dol_trunc($libelle, 120);
|
||||
$out .= ' title="'.dol_escape_htmltag($label).'">';
|
||||
$out .= dol_trunc($label, 120);
|
||||
}
|
||||
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
|
||||
$transcode = $langs->trans("Action".$histo[$key]['acode']);
|
||||
$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing');
|
||||
$label = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing');
|
||||
$label .= ' - '.$histo[$key]['note'];
|
||||
$out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'"';
|
||||
$out .= ' title="'.dol_escape_htmltag($libelle).'">';
|
||||
$out .= img_object($langs->trans("ShowEMailing"), "email").' ';
|
||||
$out .= dol_trunc($libelle, 120);
|
||||
$out .= ' title="'.dol_escape_htmltag($label).'">';
|
||||
//$out .= img_object($langs->trans("EMailing").'<br>'.$histo[$key]['note'], "email").' ';
|
||||
$out .= dol_trunc($label, 120);
|
||||
$out .= '</a>';
|
||||
}
|
||||
$out .= '</td>';
|
||||
|
|
@ -2625,7 +2651,7 @@ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj)
|
|||
if (isModEnabled('mailing') && !empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) {
|
||||
$sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
|
||||
$sql2 .= ", null as fk_element, '' as elementtype, null as contact_id";
|
||||
$sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
|
||||
$sql2 .= ", 'AC_EMAILING' as code, 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
|
||||
$sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action
|
||||
if (is_object($filterobj) && get_class($filterobj) == 'Societe') {
|
||||
$sql2 .= ", '' as lastname, '' as firstname";
|
||||
|
|
|
|||
|
|
@ -3174,7 +3174,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
|
|||
$original_file = $conf->fckeditor->dir_output.'/'.$original_file;
|
||||
} elseif ($modulepart == 'user' && !empty($conf->user->dir_output)) {
|
||||
// Wrapping for users
|
||||
$canreaduser = (!empty($fuser->admin) || $fuser->rights->user->user->{$lire});
|
||||
$canreaduser = (!empty($fuser->admin) || $fuser->hasRight('user', 'user', 'lire'));
|
||||
if ($fuser->id == (int) $refname) {
|
||||
$canreaduser = 1;
|
||||
} // A user can always read its own card
|
||||
|
|
|
|||
|
|
@ -10513,10 +10513,11 @@ function dol_osencode($str)
|
|||
* @param string $fieldid Field to get
|
||||
* @param int $entityfilter Filter by entity
|
||||
* @param string $filters Filters to add. WARNING: string must be escaped for SQL and not coming from user input.
|
||||
* @param bool $useCache If true (default), cache will be queried and updated.
|
||||
* @return int<-1,max>|string ID of code if OK, 0 if key empty, -1 if KO
|
||||
* @see $langs->getLabelFromKey
|
||||
*/
|
||||
function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '')
|
||||
function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '', $useCache = true)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
|
@ -10526,7 +10527,7 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid =
|
|||
}
|
||||
|
||||
// Check in cache
|
||||
if (isset($conf->cache['codeid'][$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
|
||||
if ($useCache && isset($conf->cache['codeid'][$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
|
||||
return $conf->cache['codeid'][$tablename][$key][$fieldid]; // Found in cache
|
||||
}
|
||||
|
||||
|
|
@ -10549,14 +10550,16 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid =
|
|||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$valuetoget = '';
|
||||
if ($obj) {
|
||||
$conf->cache['codeid'][$tablename][$key][$fieldid] = $obj->valuetoget;
|
||||
$valuetoget = $obj->valuetoget;
|
||||
$conf->cache['codeid'][$tablename][$key][$fieldid] = $valuetoget;
|
||||
} else {
|
||||
$conf->cache['codeid'][$tablename][$key][$fieldid] = '';
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
return $conf->cache['codeid'][$tablename][$key][$fieldid];
|
||||
return $valuetoget;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1506,6 +1506,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
|
|||
$note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
|
||||
$dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);
|
||||
|
||||
$multilangsactive = getDolGlobalInt('MAIN_MULTILANGS');
|
||||
|
||||
if ($issupplierline) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||
$prodser = new ProductFournisseur($db);
|
||||
|
|
@ -1518,11 +1520,55 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
|
|||
}
|
||||
}
|
||||
|
||||
//id
|
||||
$idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false);
|
||||
if ($idprod) {
|
||||
$prodser->fetch($idprod);
|
||||
//load multilangs
|
||||
if ($multilangsactive) {
|
||||
$prodser->getMultiLangs();
|
||||
$object->lines[$i]->multilangs = $prodser->multilangs;
|
||||
}
|
||||
}
|
||||
//label
|
||||
if (!empty($object->lines[$i]->label)) {
|
||||
$label = $object->lines[$i]->label;
|
||||
} else {
|
||||
if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['label']) && $multilangsactive) {
|
||||
$label = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['label'];
|
||||
} else {
|
||||
if (!empty($object->lines[$i]->product_label)) {
|
||||
$label = $object->lines[$i]->product_label;
|
||||
} else {
|
||||
$label = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
//description
|
||||
if (!empty($object->lines[$i]->desc)) {
|
||||
$desc = $object->lines[$i]->desc;
|
||||
} else {
|
||||
if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['description']) && $multilangsactive) {
|
||||
$desc = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['description'];
|
||||
} else {
|
||||
if (!empty($object->lines[$i]->description)) {
|
||||
$desc = $object->lines[$i]->description;
|
||||
} else {
|
||||
$desc = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
//ref supplier
|
||||
$ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
|
||||
//note
|
||||
$note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
|
||||
//dbatch
|
||||
$dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);
|
||||
|
||||
if ($idprod) {
|
||||
// If a predefined product and multilang and on other lang, we renamed label with label translated
|
||||
if (getDolGlobalInt('MAIN_MULTILANGS') && ($outputlangs->defaultlang != $langs->defaultlang)) {
|
||||
$translatealsoifmodified = (getDolGlobalString('MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED')); // By default if value was modified manually, we keep it (no translation because we don't have it)
|
||||
if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) {
|
||||
$translatealsoifmodified = getDolGlobalString('MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED'); // By default if value was modified manually, we keep it (no translation because we don't have it)
|
||||
|
||||
// TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
|
||||
// ($textwasnotmodified is replaced with $textwasmodifiedorcompleted and we add completion).
|
||||
|
|
|
|||
|
|
@ -197,6 +197,34 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||
}
|
||||
}
|
||||
|
||||
// Send email to assignee if an assignee was set at creation
|
||||
if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id && empty($object->context['disableticketemail'])) {
|
||||
$userstat = new User($this->db);
|
||||
$res = $userstat->fetch($object->fk_user_assign);
|
||||
if ($res > 0) {
|
||||
// Send email to notification email
|
||||
if (!getDolGlobalString('TICKET_DISABLE_ALL_MAILS')) {
|
||||
// Send email to assigned user
|
||||
$sendto = $userstat->email;
|
||||
if (!getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) {
|
||||
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
|
||||
}
|
||||
|
||||
if (!empty($sendto)) {
|
||||
$this->composeAndSendAssigneeMessage($sendto, $subject_assignee, $body_assignee, $see_ticket_assignee, $object, $langs);
|
||||
}
|
||||
|
||||
if (!getDolUserString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) {
|
||||
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->error = $userstat->error;
|
||||
$this->errors = $userstat->errors;
|
||||
}
|
||||
}
|
||||
|
||||
// Send email to customer
|
||||
// Note: $object->context['disableticketemail'] is set to 1 by public interface at creation because email sending is already managed by page
|
||||
// $object->context['createdfrompublicinterface'] may also be defined when creation done from public interface
|
||||
|
|
|
|||
|
|
@ -256,6 +256,13 @@ class Donations extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->don->array_options[$index] = $this->_checkValForAPI($field, $val, $this->don);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->don->$field = $this->_checkValForAPI($field, $value, $this->don);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -483,6 +483,7 @@ class Shipments extends DolibarrApi
|
|||
$this->shipment->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->shipment->array_options[$index] = $this->_checkValForAPI($field, $val, $this->shipment);
|
||||
|
|
|
|||
|
|
@ -460,6 +460,13 @@ class ExpenseReports extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->expensereport->array_options[$index] = $this->_checkValForAPI($field, $val, $this->expensereport);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->expensereport->$field = $this->_checkValForAPI($field, $value, $this->expensereport);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -694,6 +694,7 @@ class ExpenseReport extends CommonObject
|
|||
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d";
|
||||
if ($ref) {
|
||||
$sql .= " WHERE d.ref = '".$this->db->escape($ref)."'";
|
||||
$sql .= " AND d.entity IN (".getEntity('expensereport').")";
|
||||
} else {
|
||||
$sql .= " WHERE d.rowid = ".((int) $id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ class SupplierInvoices extends DolibarrApi
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->invoice->$field = $this->_checkValForAPI($field, $value, $this->invoice);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -312,6 +312,7 @@ class SupplierOrders extends DolibarrApi
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->order->$field = $this->_checkValForAPI($field, $value, $this->order);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ class Odf
|
|||
public $userdefined = array();
|
||||
|
||||
const PIXEL_TO_CM = 0.026458333;
|
||||
const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/s';
|
||||
const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/';
|
||||
const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1(\s.*)?>).)*)<\/\1>))/s';
|
||||
const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(((?!<\1(\s.*)?>).)*)<\/\1>))/';
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,4 +22,5 @@ ALTER TABLE llx_blockedlog ADD INDEX entity (entity);
|
|||
ALTER TABLE llx_blockedlog ADD INDEX fk_user (fk_user);
|
||||
ALTER TABLE llx_blockedlog ADD INDEX entity_action_certified (entity,action,certified);
|
||||
|
||||
ALTER TABLE llx_blockedlog ADD INDEX entity_rowid (entity, rowid); -- for the "SELECT rowid, signature FROM llx_blockedlog FORCE INDEX entity_rowid WHERE entity = x AND rowid < z ORDER BY rowid DESC"
|
||||
-- We add this index for the "SELECT rowid, signature FROM llx_blockedlog FORCE INDEX entity_rowid WHERE entity = x AND rowid < z ORDER BY rowid DESC"
|
||||
ALTER TABLE llx_blockedlog ADD INDEX entity_rowid (entity, rowid);
|
||||
|
|
|
|||
|
|
@ -311,6 +311,13 @@ class KnowledgeManagement extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->knowledgerecord->array_options[$index] = $this->_checkValForAPI($field, $val, $this->knowledgerecord);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->knowledgerecord->$field = $this->_checkValForAPI($field, $value, $this->knowledgerecord);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ YourEMail=Email to receive payment confirmation
|
|||
STRIPE_PAYONLINE_SENDEMAIL=Email notification after a payment attempt (success or fail)
|
||||
Creditor=Creditor
|
||||
PaymentCode=Payment code
|
||||
StripeAutoRecordPayout=Enable the auto recording of payout (when Stripe do a payout and call the webhook IPN payout.create/payout.paid)
|
||||
StripeDoPayment=Pay with Stripe
|
||||
YouWillBeRedirectedOnStripe=You will be redirected on secured Stripe page to input you credit card information
|
||||
Continue=Next
|
||||
|
|
|
|||
|
|
@ -359,6 +359,7 @@ class Loan extends CommonObject
|
|||
$accountline->fetch($line_url['fk_bank']);
|
||||
$result = $accountline->delete_urls($user);
|
||||
if ($result < 0) {
|
||||
$this->errors = array_merge($this->errors, [$accountline->error], $accountline->errors);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,6 +288,13 @@ class MyModuleApi extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->myobject->array_options[$index] = $this->_checkValForAPI($field, $val, $this->myobject);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->myobject->$field = $this->_checkValForAPI($field, $value, $this->myobject);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -235,6 +235,13 @@ class Mos extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->mo->array_options[$index] = $this->_checkValForAPI($field, $val, $this->mo);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->mo->$field = $this->_checkValForAPI($field, $value, $this->mo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -249,6 +249,12 @@ class Partnerships extends DolibarrApi
|
|||
$this->partnership->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
|
||||
continue;
|
||||
}
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->partnership->array_options[$index] = $this->_checkValForAPI($field, $val, $this->partnership);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->partnership->$field = $this->_checkValForAPI($field, $value, $this->partnership);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,6 +400,7 @@ class Products extends DolibarrApi
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->product->$field = $this->_checkValForAPI($field, $value, $this->product);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,6 +217,13 @@ class Warehouses extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->warehouse->array_options[$index] = $this->_checkValForAPI($field, $val, $this->warehouse);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->warehouse->$field = $this->_checkValForAPI($field, $value, $this->warehouse);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -194,8 +194,16 @@ if (!empty($_SESSION['ipaddress'])) { // To avoid to make action twice
|
|||
|
||||
// Send warning of error to administrator
|
||||
if ($sendemail) {
|
||||
// Get default language to use for the company for supervision emails
|
||||
$myCompanyDefaultLang = $mysoc->default_lang;
|
||||
if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang === 'auto') {
|
||||
// We must guess the language from the company country. We must not use the language of the visitor. This is a technical email for supervision
|
||||
// so it must always be into the same language.
|
||||
$myCompanyDefaultLang = getLanguageCodeFromCountryCode($mysoc->country_code);
|
||||
}
|
||||
|
||||
$companylangs = new Translate('', $conf);
|
||||
$companylangs->setDefaultLang($mysoc->default_lang);
|
||||
$companylangs->setDefaultLang($myCompanyDefaultLang);
|
||||
$companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox', 'stripe'));
|
||||
|
||||
$from = getDolGlobalString("MAIN_MAIL_EMAIL_FROM");
|
||||
|
|
|
|||
|
|
@ -1957,8 +1957,16 @@ if ($ispaymentok) {
|
|||
|
||||
// Send an email to the admins
|
||||
if ($sendemail) {
|
||||
// Get default language to use for the company for supervision emails
|
||||
$myCompanyDefaultLang = $mysoc->default_lang;
|
||||
if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang === 'auto') {
|
||||
// We must guess the language from the company country. We must not use the language of the visitor. This is a technical email for supervision
|
||||
// so it must always be into the same language.
|
||||
$myCompanyDefaultLang = getLanguageCodeFromCountryCode($mysoc->country_code);
|
||||
}
|
||||
|
||||
$companylangs = new Translate('', $conf);
|
||||
$companylangs->setDefaultLang($mysoc->default_lang);
|
||||
$companylangs->setDefaultLang($myCompanyDefaultLang);
|
||||
$companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox', 'stripe'));
|
||||
|
||||
$sendto = $sendemail;
|
||||
|
|
|
|||
|
|
@ -178,14 +178,14 @@ top_httphead();
|
|||
dol_syslog("***** Stripe IPN was called with event->type=".$event->type." service=".$service);
|
||||
|
||||
|
||||
if ($event->type == 'payout.created') {
|
||||
// When a payout is create by Stripe to transfer money to your account
|
||||
if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_PAYOUT')) {
|
||||
// When a payout is created by Stripe to transfer money to your account
|
||||
$error = 0;
|
||||
|
||||
$result = dolibarr_set_const($db, $service."_NEXTPAYOUT", date('Y-m-d H:i:s', $event->data->object->arrival_date), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if ($result > 0) {
|
||||
$subject = $societeName.' - [NOTIFICATION] Stripe payout scheduled';
|
||||
$subject = '['.$societeName.'] Notification - Stripe payout scheduled';
|
||||
if (!empty($user->email)) {
|
||||
$sendto = dolGetFirstLastname($user->firstname, $user->lastname)." <".$user->email.">";
|
||||
} else {
|
||||
|
|
@ -221,7 +221,7 @@ if ($event->type == 'payout.created') {
|
|||
http_response_code(500);
|
||||
return -1;
|
||||
}
|
||||
} elseif ($event->type == 'payout.paid') {
|
||||
} elseif ($event->type == 'payout.paid' && getDolGlobalString('STRIPE_AUTO_RECORD_PAYOUT')) {
|
||||
// When a payout to transfer money to your account is completely done
|
||||
$error = 0;
|
||||
$result = dolibarr_set_const($db, $service."_NEXTPAYOUT", 0, 'chaine', 0, '', $conf->entity);
|
||||
|
|
@ -249,6 +249,8 @@ if ($event->type == 'payout.created') {
|
|||
$typefrom = 'PRE';
|
||||
$typeto = 'VIR';
|
||||
|
||||
$db->begin();
|
||||
|
||||
if (!$error) {
|
||||
$bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1 * (float) price2num($amount), '', '', $user);
|
||||
}
|
||||
|
|
@ -274,38 +276,47 @@ if ($event->type == 'payout.created') {
|
|||
if (!($result > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
// Send email
|
||||
if (!$error) {
|
||||
$subject = '['.$societeName.'] - NotificationOTIFICATION] Stripe payout done';
|
||||
if (!empty($user->email)) {
|
||||
$sendto = dolGetFirstLastname($user->firstname, $user->lastname)." <".$user->email.">";
|
||||
} else {
|
||||
$sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') . '" <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>';
|
||||
}
|
||||
$replyto = $sendto;
|
||||
$sendtocc = '';
|
||||
if (getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL')) {
|
||||
$sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL') . '" <' . getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>';
|
||||
}
|
||||
|
||||
$message = "A bank transfer of ".price2num($event->data->object->amount / 100)." ".$event->data->object->currency." has been done to your account the ".dol_print_date($event->data->object->arrival_date, 'dayhour');
|
||||
|
||||
$mailfile = new CMailFile(
|
||||
$subject,
|
||||
$sendto,
|
||||
$replyto,
|
||||
$message,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$sendtocc,
|
||||
'',
|
||||
0,
|
||||
-1
|
||||
);
|
||||
|
||||
$ret = $mailfile->sendfile();
|
||||
}
|
||||
}
|
||||
|
||||
$subject = $societeName.' - [NOTIFICATION] Stripe payout done';
|
||||
if (!empty($user->email)) {
|
||||
$sendto = dolGetFirstLastname($user->firstname, $user->lastname)." <".$user->email.">";
|
||||
} else {
|
||||
$sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') . '" <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>';
|
||||
}
|
||||
$replyto = $sendto;
|
||||
$sendtocc = '';
|
||||
if (getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL')) {
|
||||
$sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL') . '" <' . getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>';
|
||||
}
|
||||
|
||||
$message = "A bank transfer of ".price2num($event->data->object->amount / 100)." ".$event->data->object->currency." has been done to your account the ".dol_print_date($event->data->object->arrival_date, 'dayhour');
|
||||
|
||||
$mailfile = new CMailFile(
|
||||
$subject,
|
||||
$sendto,
|
||||
$replyto,
|
||||
$message,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$sendtocc,
|
||||
'',
|
||||
0,
|
||||
-1
|
||||
);
|
||||
|
||||
$ret = $mailfile->sendfile();
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$error++;
|
||||
|
|
|
|||
|
|
@ -496,6 +496,13 @@ class Receptions extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->reception->array_options[$index] = $this->_checkValForAPI($field, $val, $this->reception);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->reception->$field = $this->_checkValForAPI($field, $value, $this->reception);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ class Contacts extends DolibarrApi
|
|||
}
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->contact->array_options[$index] = $this->_checkValForAPI('extrafields', $val, $this->contact);
|
||||
$this->contact->array_options[$index] = $this->_checkValForAPI($field, $val, $this->contact);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ class Thirdparties extends DolibarrApi
|
|||
}
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->company->array_options[$index] = $val;
|
||||
$this->company->array_options[$index] = $this->_checkValForAPI($field, $val, $this->company);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -379,18 +379,30 @@ print '<input class="minwidth300" type="text" name="ONLINE_PAYMENT_CREDITOR" val
|
|||
print ' <span class="opacitymedium">'.$langs->trans("Example").': '.$mysoc->name.'</span>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("StripeUserAccountForActions").'</td><td>';
|
||||
print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(getDolGlobalString('STRIPE_USER_ACCOUNT_FOR_ACTIONS'), 'STRIPE_USER_ACCOUNT_FOR_ACTIONS', 0);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("BankAccount").'</td><td>';
|
||||
print img_picto('', 'bank_account', 'class="pictofixedwidth"');
|
||||
$form->select_comptes(getDolGlobalString('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS'), 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // What is this for ?
|
||||
|
||||
// Param to record automatically payouts (received from IPN payout.payed and payout.created)
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("StripeAutoRecordPayout").'</td><td>';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print ajax_constantonoff('STRIPE_AUTO_RECORD_PAYOUT', array(), null, 0, 0, 1);
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
print $form->selectarray("STRIPE_AUTO_RECORD_PAYOUT", $arrval, getDolGlobalInt('STRIPE_AUTO_RECORD_PAYOUT'));
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if (getDolGlobalInt('STRIPE_AUTO_RECORD_PAYOUT')) {
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("StripeUserAccountForActions").'</td><td>';
|
||||
print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(getDolGlobalString('STRIPE_USER_ACCOUNT_FOR_ACTIONS'), 'STRIPE_USER_ACCOUNT_FOR_ACTIONS', 0);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("BankAccountForBankTransfer").'</td><td>';
|
||||
print img_picto('', 'bank_account', 'class="pictofixedwidth"');
|
||||
|
|
|
|||
|
|
@ -402,6 +402,16 @@ class Tickets extends DolibarrApi
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field == 'id') {
|
||||
continue;
|
||||
}
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->ticket->array_options[$index] = $this->_checkValForAPI($field, $val, $this->ticket);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->ticket->$field = $this->_checkValForAPI($field, $value, $this->ticket);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -407,6 +407,12 @@ class Users extends DolibarrApi
|
|||
$this->useraccount->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
|
||||
continue;
|
||||
}
|
||||
if ($field == 'array_options' && is_array($value)) {
|
||||
foreach ($value as $index => $val) {
|
||||
$this->useraccount->array_options[$index] = $this->_checkValForAPI($field, $val, $this->useraccount);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (DolibarrApiAccess::$user->admin) { // If user for API is admin
|
||||
if ($field == 'admin' && $value != $this->useraccount->admin && empty($value)) {
|
||||
|
|
|
|||
|
|
@ -795,8 +795,8 @@ class ProductCombination
|
|||
$price_impact = $forced_pricevar;
|
||||
}
|
||||
|
||||
if (!array($price_var_percent)) {
|
||||
$price_var_percent[1] = (float) $price_var_percent;
|
||||
if (!is_array($price_var_percent)) {
|
||||
$price_var_percent = array(1 => (bool) $price_var_percent);
|
||||
}
|
||||
|
||||
$newcomb = new ProductCombination($this->db);
|
||||
|
|
@ -998,13 +998,26 @@ class ProductCombination
|
|||
$variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val;
|
||||
}
|
||||
|
||||
$variation_price_percentage = $combination->variation_price_percentage;
|
||||
$variation_price = $combination->variation_price;
|
||||
|
||||
if (getDolGlobalInt('PRODUIT_MULTIPRICES') && getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') > 1) {
|
||||
$variation_price_percentage = [ ];
|
||||
$variation_price = [ ];
|
||||
|
||||
foreach ($combination->combination_price_levels as $productCombinationLevel) {
|
||||
$variation_price_percentage[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price_percentage;
|
||||
$variation_price[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->createProductCombination(
|
||||
$user,
|
||||
$destProduct,
|
||||
$variations,
|
||||
array(),
|
||||
$combination->variation_price_percentage,
|
||||
$combination->variation_price,
|
||||
$variation_price_percentage,
|
||||
$variation_price,
|
||||
$combination->variation_weight
|
||||
) < 0) {
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -218,33 +218,45 @@ class ODFTest extends CommonClassTest
|
|||
'charset' => null,
|
||||
'expected' => mb_convert_encoding('text with <text:span text:style-name="boldText">intricated<text:span text:style-name="underlineText">tags</text:span></text:span>', 'UTF-8', 'ISO-8859-1'),
|
||||
],
|
||||
24 => [
|
||||
'to_convert' => "text with <strong>two</strong> (strong) <strong>tags</strong>",
|
||||
'encode' => true,
|
||||
'charset' => null,
|
||||
'expected' => utf8_encode('text with <text:span text:style-name="boldText">two</text:span> (strong) <text:span text:style-name="boldText">tags</text:span>'),
|
||||
],
|
||||
25 => [
|
||||
'to_convert' => "text with <strong class=\"whatever\">two</strong> (strong) <strong class=\"the weather\">tags and <u>intricated</u> underline </strong>",
|
||||
'encode' => true,
|
||||
'charset' => null,
|
||||
'expected' => utf8_encode('text with <text:span text:style-name="boldText">two</text:span> (strong) <text:span text:style-name="boldText">tags and <text:span text:style-name="underlineText">intricated</text:span> underline </text:span>'),
|
||||
],
|
||||
|
||||
// One can also pass html-encoded string to the method
|
||||
24 => [
|
||||
26 => [
|
||||
'to_convert' => 'One&two',
|
||||
'encode' => true,
|
||||
'charset' => null,
|
||||
'expected' => 'One&two',
|
||||
],
|
||||
25 => [
|
||||
27 => [
|
||||
'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>",
|
||||
'encode' => false,
|
||||
'charset' => 'UTF-8',
|
||||
'expected' => 'text with <text:span text:style-name="boldText">strong, </text:span><text:span text:style-name="italicText">emphasis</text:span> and <text:span text:style-name="underlineText">underlined</text:span> words with <text:span text:style-name="italicText">it@lic sp&ciàlchärs éè l\'</text:span>',
|
||||
],
|
||||
26 => [
|
||||
28 => [
|
||||
'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>",
|
||||
'encode' => true,
|
||||
'charset' => 'UTF-8',
|
||||
'expected' => 'text with <text:span text:style-name="boldText">strong, </text:span><text:span text:style-name="italicText">emphasis</text:span> and <text:span text:style-name="underlineText">underlined</text:span> words with <text:span text:style-name="italicText">it@lic sp&ciàlchärs éè l'</text:span>',
|
||||
],
|
||||
27 => [
|
||||
29 => [
|
||||
'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>",
|
||||
'encode' => false,
|
||||
'charset' => null,
|
||||
'expected' => mb_convert_encoding('text with <text:span text:style-name="boldText">strong, </text:span><text:span text:style-name="italicText">emphasis</text:span> and <text:span text:style-name="underlineText">underlined</text:span> words with <text:span text:style-name="italicText">it@lic sp&ciàlchärs éè l\'</text:span>', 'UTF-8', 'ISO-8859-1'),
|
||||
],
|
||||
28 => [
|
||||
30 => [
|
||||
'to_convert' => "text with <strong>strong, </strong><em>emphasis</em> and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>",
|
||||
'encode' => true,
|
||||
'charset' => null,
|
||||
|
|
@ -263,20 +275,20 @@ class ODFTest extends CommonClassTest
|
|||
// Following tests reflect the current behavior. They may evolve if the method behavior changes.
|
||||
|
||||
// The method removes hyperlinks and tags that are not dealt with.
|
||||
29 => [
|
||||
31 => [
|
||||
'to_convert' => '123 <a href="/test.php">trucmachin > truc < troc > trac</a>bla bla',
|
||||
'encode' => true,
|
||||
'charset' => null,
|
||||
'expected' => "123 trucmachin > truc < troc > tracbla bla",
|
||||
],
|
||||
30 => [
|
||||
32 => [
|
||||
'to_convert' => '123 <h3>Title</h3> bla',
|
||||
'encode' => true,
|
||||
'charset' => null,
|
||||
'expected' => "123 Title bla",
|
||||
],
|
||||
// HTML should not take \n into account, but only <br />.
|
||||
31 => [
|
||||
33 => [
|
||||
'to_convert' => "text with <strong>strong text </strong>, a line\nbreak and <u>underlined</u> words with <i>it@lic sp&ciàlchärs éè l'</i>",
|
||||
'encode' => false,
|
||||
'charset' => 'UTF-8',
|
||||
|
|
@ -295,7 +307,7 @@ class ODFTest extends CommonClassTest
|
|||
} else {
|
||||
$res = $odf->convertVarToOdf($case['to_convert'], $case['encode']);
|
||||
}
|
||||
$this->assertEquals($res, $case['expected']);
|
||||
$this->assertEquals($case['expected'], $res);
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user