Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
68708d7344
452
htdocs/api/class/api_dictionary.class.php
Normal file
452
htdocs/api/class/api_dictionary.class.php
Normal file
@ -0,0 +1,452 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Neil Orley <neil.orley@oeris.fr>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
|
||||
|
||||
/**
|
||||
* API class for payment type (content of the paiement dictionary)
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class Dictionary extends DolibarrApi
|
||||
{
|
||||
private $translations = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of payments types.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number {@min 0}
|
||||
* @param int $active Payment type is active or not {@min 0} {@max 1}
|
||||
* @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')"
|
||||
*
|
||||
* @url GET payments
|
||||
*
|
||||
* @return List of payment types
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$sql = "SELECT id, code, type, libelle as label, module";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t";
|
||||
$sql.= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of payment types : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of countries.
|
||||
*
|
||||
* The names of the countries will be translated to the given language if
|
||||
* the $lang parameter is provided. The value of $lang must be a language
|
||||
* code supported by Dolibarr, for example 'en_US' or 'fr_FR'.
|
||||
* The returned list is sorted by country ID.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @param string $filter To filter the countries by name
|
||||
* @param string $lang Code of the language the label of the countries must be translated to
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||
* @return List of countries
|
||||
*
|
||||
* @url GET countries
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
// Note: The filter is not applied in the SQL request because it must
|
||||
// be applied to the translated names, not to the names in database.
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
|
||||
$sql.=" WHERE 1 = 1";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$country = new Ccountry($this->db);
|
||||
if ($country->fetch($obj->rowid) > 0) {
|
||||
// Translate the name of the country if needed
|
||||
// and then apply the filter if there is one.
|
||||
$this->translateLabel($country, $lang);
|
||||
|
||||
if (empty($filter) || stripos($country->label, $filter) !== FALSE) {
|
||||
$list[] = $this->_cleanObjectDatas($country);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of countries : '.$country->error);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get country by ID.
|
||||
*
|
||||
* @param int $id ID of country
|
||||
* @param string $lang Code of the language the name of the
|
||||
* country must be translated to
|
||||
*
|
||||
* @url GET countries/{id}
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function getCountryByID($id, $lang = '')
|
||||
{
|
||||
$country = new Ccountry($this->db);
|
||||
|
||||
if ($country->fetch($id) < 0) {
|
||||
throw new RestException(503, 'Error when retrieving country : '.$country->error);
|
||||
}
|
||||
else if ($country->fetch($id) == 0) {
|
||||
throw new RestException(404, 'country not found');
|
||||
}
|
||||
|
||||
$this->translateLabel($country, $lang);
|
||||
|
||||
return $this->_cleanObjectDatas($country);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param object $object Object to clean
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object)
|
||||
{
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
unset($object->error);
|
||||
unset($object->errors);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the name of the country to the given language.
|
||||
*
|
||||
* @param Ccountry $country Country
|
||||
* @param string $lang Code of the language the name of the
|
||||
* country must be translated to
|
||||
*/
|
||||
private function translateLabel($country, $lang)
|
||||
{
|
||||
if (!empty($lang)) {
|
||||
// Load the translations if this is a new language.
|
||||
if ($this->translations == null || $this->translations->getDefaultLang() !== $lang) {
|
||||
global $conf;
|
||||
$this->translations = new Translate('', $conf);
|
||||
$this->translations->setDefaultLang($lang);
|
||||
$this->translations->load('dict');
|
||||
}
|
||||
if ($country->code) {
|
||||
$key = 'Country'.$country->code;
|
||||
$translation = $this->translations->trans($key);
|
||||
if ($translation != $key) {
|
||||
$country->label = html_entity_decode($translation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of events types.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @param string $type To filter on type of event
|
||||
* @param string $module To filter on module events
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||
* @return List of events types
|
||||
*
|
||||
* @url GET events
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function getListOfEvents($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$sql = "SELECT id, code, type, libelle as label, module";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
|
||||
$sql.= " WHERE t.active = 1";
|
||||
if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
|
||||
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of events types : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of extra fields.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...)
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')"
|
||||
* @return List of events types
|
||||
*
|
||||
* @url GET extrafields
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
if ($type == 'thirdparty') $type='societe';
|
||||
if ($type == 'contact') $type='socpeople';
|
||||
|
||||
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t";
|
||||
$sql.= " WHERE t.entity IN (".getEntity('extrafields').")";
|
||||
if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
while ($tab = $this->db->fetch_object($resql))
|
||||
{
|
||||
// New usage
|
||||
$list[$tab->elementtype][$tab->name]['type']=$tab->type;
|
||||
$list[$tab->elementtype][$tab->name]['label']=$tab->label;
|
||||
$list[$tab->elementtype][$tab->name]['size']=$tab->size;
|
||||
$list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype;
|
||||
$list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault;
|
||||
$list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed;
|
||||
$list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique;
|
||||
$list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired;
|
||||
$list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : '');
|
||||
$list[$tab->elementtype][$tab->name]['pos']=$tab->pos;
|
||||
$list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable;
|
||||
$list[$tab->elementtype][$tab->name]['perms']=$tab->perms;
|
||||
$list[$tab->elementtype][$tab->name]['list']=$tab->list;
|
||||
$list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
if (! count($list))
|
||||
{
|
||||
throw new RestException(404, 'No extrafield found');
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of towns.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @param string $zipcode To filter on zipcode
|
||||
* @param string $town To filter on city name
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||
* @return List of towns
|
||||
*
|
||||
* @url GET towns
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
|
||||
$sql.= " WHERE t.active = 1";
|
||||
if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
|
||||
if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of towns : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,184 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
|
||||
|
||||
/**
|
||||
* API class for countries
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class DictionaryCountries extends DolibarrApi
|
||||
{
|
||||
private $translations = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of countries.
|
||||
*
|
||||
* The names of the countries will be translated to the given language if
|
||||
* the $lang parameter is provided. The value of $lang must be a language
|
||||
* code supported by Dolibarr, for example 'en_US' or 'fr_FR'.
|
||||
* The returned list is sorted by country ID.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @param string $filter To filter the countries by name
|
||||
* @param string $lang Code of the language the label of the countries must be translated to
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||
* @return List of countries
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
// Note: The filter is not applied in the SQL request because it must
|
||||
// be applied to the translated names, not to the names in database.
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
|
||||
$sql.=" WHERE 1 = 1";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$country = new Ccountry($this->db);
|
||||
if ($country->fetch($obj->rowid) > 0) {
|
||||
// Translate the name of the country if needed
|
||||
// and then apply the filter if there is one.
|
||||
$this->translateLabel($country, $lang);
|
||||
|
||||
if (empty($filter) || stripos($country->label, $filter) !== FALSE) {
|
||||
$list[] = $this->_cleanObjectDatas($country);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of countries : '.$country->error);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get country by ID.
|
||||
*
|
||||
* @param int $id ID of country
|
||||
* @param string $lang Code of the language the name of the
|
||||
* country must be translated to
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id, $lang = '')
|
||||
{
|
||||
$country = new Ccountry($this->db);
|
||||
|
||||
if ($country->fetch($id) < 0) {
|
||||
throw new RestException(503, 'Error when retrieving country : '.$country->error);
|
||||
}
|
||||
else if ($country->fetch($id) == 0) {
|
||||
throw new RestException(404, 'country not found');
|
||||
}
|
||||
|
||||
$this->translateLabel($country, $lang);
|
||||
|
||||
return $this->_cleanObjectDatas($country);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param object $object Object to clean
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object)
|
||||
{
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
unset($object->error);
|
||||
unset($object->errors);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the name of the country to the given language.
|
||||
*
|
||||
* @param Ccountry $country Country
|
||||
* @param string $lang Code of the language the name of the
|
||||
* country must be translated to
|
||||
*/
|
||||
private function translateLabel($country, $lang)
|
||||
{
|
||||
if (!empty($lang)) {
|
||||
// Load the translations if this is a new language.
|
||||
if ($this->translations == null || $this->translations->getDefaultLang() !== $lang) {
|
||||
global $conf;
|
||||
$this->translations = new Translate('', $conf);
|
||||
$this->translations->setDefaultLang($lang);
|
||||
$this->translations->load('dict');
|
||||
}
|
||||
if ($country->code) {
|
||||
$key = 'Country'.$country->code;
|
||||
$translation = $this->translations->trans($key);
|
||||
if ($translation != $key) {
|
||||
$country->label = html_entity_decode($translation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,100 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
|
||||
/**
|
||||
* API class for events type (content of the actioncomm dictionary)
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class DictionaryEvents extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of events types.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @param string $type To filter on type of event
|
||||
* @param string $module To filter on module events
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||
* @return List of events types
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$sql = "SELECT id, code, type, libelle as label, module";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
|
||||
$sql.= " WHERE t.active = 1";
|
||||
if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
|
||||
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of events types : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,112 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
//require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
||||
|
||||
/**
|
||||
* API class for extra fields (content of the extrafields)
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class DictionaryExtraFields extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of extra fields.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...)
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')"
|
||||
* @return List of events types
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function index($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
if ($type == 'thirdparty') $type='societe';
|
||||
if ($type == 'contact') $type='socpeople';
|
||||
|
||||
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t";
|
||||
$sql.= " WHERE t.entity IN (".getEntity('extrafields').")";
|
||||
if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
while ($tab = $this->db->fetch_object($resql))
|
||||
{
|
||||
// New usage
|
||||
$list[$tab->elementtype][$tab->name]['type']=$tab->type;
|
||||
$list[$tab->elementtype][$tab->name]['label']=$tab->label;
|
||||
$list[$tab->elementtype][$tab->name]['size']=$tab->size;
|
||||
$list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype;
|
||||
$list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault;
|
||||
$list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed;
|
||||
$list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique;
|
||||
$list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired;
|
||||
$list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : '');
|
||||
$list[$tab->elementtype][$tab->name]['pos']=$tab->pos;
|
||||
$list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable;
|
||||
$list[$tab->elementtype][$tab->name]['perms']=$tab->perms;
|
||||
$list[$tab->elementtype][$tab->name]['list']=$tab->list;
|
||||
$list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
if (! count($list))
|
||||
{
|
||||
throw new RestException(404, 'No extrafield found');
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
|
||||
|
||||
/**
|
||||
* API class for towns (content of the ziptown dictionary)
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class DictionaryTowns extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of towns.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number (starting from zero)
|
||||
* @param string $zipcode To filter on zipcode
|
||||
* @param string $town To filter on city name
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
|
||||
* @return List of towns
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function index($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
|
||||
$sql.= " WHERE t.active = 1";
|
||||
if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
|
||||
if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of towns : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
@ -771,9 +771,9 @@ if ($action == 'create')
|
||||
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
|
||||
//For external user force the company to user company
|
||||
if (!empty($user->societe_id)) {
|
||||
print $form->select_thirdparty_list($user->societe_id, 'socid', '', 1, 1, 0, $events);
|
||||
print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events);
|
||||
} else {
|
||||
print $form->select_thirdparty_list('', 'socid', '', 'SelectThirdParty', 1, 0, $events);
|
||||
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events);
|
||||
}
|
||||
|
||||
}
|
||||
@ -781,7 +781,7 @@ if ($action == 'create')
|
||||
|
||||
// Related contact
|
||||
print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
|
||||
$form->select_contacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
|
||||
$form->selectcontacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
// Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
// or see http://www.gnu.org/
|
||||
|
||||
//
|
||||
// \file htdocs/core/js/lib_batch.js
|
||||
// \brief File that include javascript functions used when dispatching batch-enabled product
|
||||
//
|
||||
|
||||
/**
|
||||
* addLineBatch
|
||||
* @deprecated replaced by addDispatchLine and moved to module folder and file fourn/js/lib_dispatch.js
|
||||
*
|
||||
* @param index int number of produt. 0 = first product line
|
||||
*/
|
||||
function addLineBatch(index)
|
||||
{
|
||||
var nme = 'dluo_0_'+index;
|
||||
$row=$("tr[name='"+nme+"']").clone(true);
|
||||
$row.find("input[name^='qty']").val('');
|
||||
var trs = $("tr[name^='dluo_'][name$='_"+index+"']"); /* trs.length = position of line for batch */
|
||||
var newrow=$row.html().replace(/_0_/g,"_"+(trs.length)+"_");
|
||||
$row.html(newrow);
|
||||
//clear value
|
||||
$row.find("input[name^='qty']").val('');
|
||||
//change name of row
|
||||
$row.attr('name','dluo_'+trs.length+'_'+index);
|
||||
$("tr[name^='dluo_'][name$='_"+index+"']:last").after($row);
|
||||
|
||||
/* Suffix of lines are: _ trs.length _ index */
|
||||
jQuery("#lot_number_"+trs.length+"_"+index).focus();
|
||||
nb = jQuery("#qty_"+(trs.length - 1)+"_"+index).val();
|
||||
if (nb > 0)
|
||||
{
|
||||
jQuery("#qty_"+(trs.length - 1)+"_"+index).val(1);
|
||||
jQuery("#qty_"+trs.length+"_"+index).val(nb - 1);
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,7 @@ class pdf_paiement
|
||||
global $langs,$conf;
|
||||
$langs->load("bills");
|
||||
$langs->load("compta");
|
||||
$langs->load("main");
|
||||
|
||||
$this->db = $db;
|
||||
$this->description = $langs->transnoentities("ListOfCustomerPayments");
|
||||
@ -77,6 +78,8 @@ class pdf_paiement
|
||||
$this->posxinvoiceamount-=10;
|
||||
$this->posxpaymentamount-=20;
|
||||
}
|
||||
// which type of document will be generated: clients (client) or providers (fourn) invoices
|
||||
$this->doc_type = "client";
|
||||
|
||||
}
|
||||
|
||||
@ -105,7 +108,6 @@ class pdf_paiement
|
||||
|
||||
$this->month=$month;
|
||||
$this->year=$year;
|
||||
|
||||
$dir=$_dir.'/'.$year;
|
||||
|
||||
if (! is_dir($dir))
|
||||
@ -120,7 +122,15 @@ class pdf_paiement
|
||||
|
||||
$month = sprintf("%02d",$month);
|
||||
$year = sprintf("%04d",$year);
|
||||
$file = $dir . "/payments-".$year."-".$month.".pdf";
|
||||
switch ($this->doc_type) {
|
||||
case "client":
|
||||
$file = $dir . "/payments-".$year."-".$month.".pdf";
|
||||
break;
|
||||
case "fourn":
|
||||
$file = $dir . "/supplier_payments-".$year."-".$month.".pdf";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
@ -148,7 +158,14 @@ class pdf_paiement
|
||||
|
||||
// count number of lines of payment
|
||||
$sql = "SELECT p.rowid as prowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p";
|
||||
switch ($this->doc_type) {
|
||||
case "client":
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p";
|
||||
break;
|
||||
case "fourn":
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
|
||||
break;
|
||||
}
|
||||
$sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
|
||||
$sql.= " AND p.entity = " . $conf->entity;
|
||||
$result = $this->db->query($sql);
|
||||
@ -158,35 +175,70 @@ class pdf_paiement
|
||||
}
|
||||
|
||||
// number of bill
|
||||
$sql = "SELECT p.datep as dp, f.facnumber";
|
||||
//$sql .= ", c.libelle as paiement_type, p.num_paiement";
|
||||
$sql.= ", c.code as paiement_code, p.num_paiement";
|
||||
$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
|
||||
$sql.= ", pf.amount as pf_amount";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= ", ba.ref as bankaccount";
|
||||
$sql.= ", p.rowid as prowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."facture as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf,";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
|
||||
$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.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= " AND p.fk_paiement = c.id ";
|
||||
$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
|
||||
if (! $user->rights->societe->client->voir && ! $socid)
|
||||
{
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
|
||||
$sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
|
||||
switch ($this->doc_type) {
|
||||
case "client":
|
||||
$sql = "SELECT p.datep as dp, f.facnumber";
|
||||
//$sql .= ", c.libelle as paiement_type, p.num_paiement";
|
||||
$sql.= ", c.code as paiement_code, p.num_paiement";
|
||||
$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
|
||||
$sql.= ", pf.amount as pf_amount";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= ", ba.ref as bankaccount";
|
||||
$sql.= ", p.rowid as prowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."facture as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf,";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
|
||||
$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.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= " AND p.fk_paiement = c.id ";
|
||||
$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
|
||||
if (! $user->rights->societe->client->voir && ! $socid)
|
||||
{
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
|
||||
$sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
|
||||
break;
|
||||
case "fourn":
|
||||
$sql = "SELECT p.datep as dp, f.ref as facnumber";
|
||||
//$sql .= ", c.libelle as paiement_type, p.num_paiement";
|
||||
$sql.= ", c.code as paiement_code, p.num_paiement";
|
||||
$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
|
||||
$sql.= ", pf.amount as pf_amount";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= ", ba.ref as bankaccount";
|
||||
$sql.= ", p.rowid as prowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p, ".MAIN_DB_PREFIX."facture_fourn as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
|
||||
$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.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= " AND p.fk_paiement = c.id ";
|
||||
$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
|
||||
if (! $user->rights->societe->client->voir && ! $socid)
|
||||
{
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
|
||||
$sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
|
||||
break;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -210,6 +262,7 @@ class pdf_paiement
|
||||
$lines[$i][6] = price($objp->pf_amount);
|
||||
$lines[$i][7] = $objp->prowid;
|
||||
$lines[$i][8] = $objp->bankaccount;
|
||||
$lines[$i][9] = $objp->paiement_amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -300,7 +353,14 @@ class pdf_paiement
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$title=$conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
$title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
|
||||
switch($this->doc_type) {
|
||||
case "client":
|
||||
$title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
|
||||
break;
|
||||
case "fourn":
|
||||
$title.=' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
|
||||
break;
|
||||
}
|
||||
$title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true);
|
||||
$pdf->SetFont('','B',$default_font_size + 1);
|
||||
$pdf->SetXY($this->marge_gauche,10);
|
||||
@ -357,10 +417,13 @@ class pdf_paiement
|
||||
*/
|
||||
function Body(&$pdf, $page, $lines, $outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$oldprowid = 0;
|
||||
$total_page = 0;
|
||||
$total = 0;
|
||||
$pdf->SetFillColor(220,220,220);
|
||||
$yp = 0;
|
||||
$numlines=count($lines);
|
||||
@ -377,13 +440,17 @@ class pdf_paiement
|
||||
}
|
||||
if ($oldprowid <> $lines[$j][7])
|
||||
{
|
||||
if ($yp > $this->tab_height -10)
|
||||
if ($yp > $this->tab_height -15)
|
||||
{
|
||||
$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
|
||||
$page++;
|
||||
$pdf->AddPage();
|
||||
$this->_pagehead($pdf, $page, 0, $outputlangs);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$yp = 0;
|
||||
$total += $total_page;
|
||||
$total_page = 0;
|
||||
}
|
||||
|
||||
$pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
|
||||
@ -398,11 +465,12 @@ class pdf_paiement
|
||||
$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
|
||||
$yp = $yp + 5;
|
||||
$total_page += $lines[$j][9];
|
||||
}
|
||||
|
||||
// Invoice number
|
||||
$pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
|
||||
$pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
|
||||
|
||||
// BankAccount
|
||||
$pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
|
||||
@ -422,6 +490,9 @@ class pdf_paiement
|
||||
$oldprowid = $lines[$j][7];
|
||||
}
|
||||
}
|
||||
$total += $total_page;
|
||||
$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('Total')." : ".price($total), 0, 'R', 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,12 +23,12 @@
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement.class.php';
|
||||
|
||||
/**
|
||||
* Classe permettant de generer les rapports de paiement
|
||||
*/
|
||||
class pdf_paiement_fourn
|
||||
class pdf_paiement_fourn extends pdf_paiement
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
@ -37,389 +37,10 @@ class pdf_paiement_fourn
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $langs,$conf;
|
||||
$langs->load("bills");
|
||||
$langs->load("compta");
|
||||
|
||||
$this->db = $db;
|
||||
$this->description = $langs->transnoentities("ListOfCustomerPayments");
|
||||
|
||||
// Dimension page pour format A4
|
||||
$this->type = 'pdf';
|
||||
$formatarray=pdf_getFormat();
|
||||
$this->page_largeur = $formatarray['width'];
|
||||
$this->page_hauteur = $formatarray['height'];
|
||||
$this->format = array($this->page_largeur,$this->page_hauteur);
|
||||
$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
|
||||
$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
|
||||
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
|
||||
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
|
||||
|
||||
$this->tab_top = 30;
|
||||
|
||||
$this->line_height = 5;
|
||||
$this->line_per_page = 40;
|
||||
$this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5; // must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
|
||||
|
||||
$this->posxdate=$this->marge_gauche+2;
|
||||
$this->posxpaymenttype=42;
|
||||
$this->posxinvoice=82;
|
||||
$this->posxbankaccount=110;
|
||||
$this->posxinvoiceamount=132;
|
||||
$this->posxpaymentamount=162;
|
||||
if ($this->page_largeur < 210) // To work with US executive format
|
||||
{
|
||||
$this->line_per_page = 35;
|
||||
$this->posxpaymenttype-=10;
|
||||
$this->posxinvoice-=0;
|
||||
$this->posxinvoiceamount-=10;
|
||||
$this->posxpaymentamount-=20;
|
||||
parent::__construct($db);
|
||||
$this->doc_type = "fourn";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction generant la rapport sur le disque
|
||||
*
|
||||
* @param string $_dir repertoire
|
||||
* @param int $month mois du rapport
|
||||
* @param int $year annee du rapport
|
||||
* @param string $outputlangs Lang output object
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function write_file($_dir, $month, $year, $outputlangs)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
global $conf, $hookmanager, $langs, $user;
|
||||
|
||||
$socid=0;
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
|
||||
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
|
||||
|
||||
$this->month=$month;
|
||||
$this->year=$year;
|
||||
|
||||
$dir=$_dir.'/'.$year;
|
||||
|
||||
if (! is_dir($dir))
|
||||
{
|
||||
$result=dol_mkdir($dir);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
$month = sprintf("%02d",$month);
|
||||
$year = sprintf("%04d",$year);
|
||||
$file = $dir . "/supplier_payments-".$year."-".$month.".pdf";
|
||||
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager=new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$pdf=pdf_getInstance($this->format);
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
|
||||
|
||||
if (class_exists('TCPDF'))
|
||||
{
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
}
|
||||
$pdf->SetFont(pdf_getPDFFont($outputlangs));
|
||||
|
||||
$num=0;
|
||||
$lines=array();
|
||||
|
||||
// count number of lines of payment
|
||||
$sql = "SELECT p.rowid as prowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
|
||||
$sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
|
||||
$sql.= " AND p.entity = " . $conf->entity;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$numpaiement = $this->db->num_rows($result);
|
||||
}
|
||||
|
||||
// number of bill
|
||||
$sql = "SELECT p.datep as dp, f.ref";
|
||||
//$sql .= ", c.libelle as paiement_type, p.num_paiement";
|
||||
$sql.= ", c.code as paiement_code, p.num_paiement";
|
||||
$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
|
||||
$sql.= ", pf.amount as pf_amount";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= ", ba.ref as bankaccount";
|
||||
$sql.= ", p.rowid as prowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p, ".MAIN_DB_PREFIX."facture_fourn as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
|
||||
$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.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= " AND p.fk_paiement = c.id ";
|
||||
$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
|
||||
if (! $user->rights->societe->client->voir && ! $socid)
|
||||
{
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
|
||||
$sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
|
||||
|
||||
dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
$var=True;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
|
||||
$lines[$i][0] = $objp->ref;
|
||||
$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true);
|
||||
$lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
|
||||
$lines[$i][3] = $objp->num_paiement;
|
||||
$lines[$i][4] = price($objp->paiement_amount);
|
||||
$lines[$i][5] = price($objp->facture_amount);
|
||||
$lines[$i][6] = price($objp->pf_amount);
|
||||
$lines[$i][7] = $objp->prowid;
|
||||
$lines[$i][8] = $objp->bankaccount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
$pages = intval(($num + $numpaiement) / $this->line_per_page);
|
||||
|
||||
if ((($num + $numpaiement) % $this->line_per_page)>0)
|
||||
{
|
||||
$pages++;
|
||||
}
|
||||
|
||||
if ($pages == 0)
|
||||
{
|
||||
// force to build at least one page if report has no line
|
||||
$pages = 1;
|
||||
}
|
||||
|
||||
$pdf->Open();
|
||||
$pagenb=0;
|
||||
$pdf->SetDrawColor(128,128,128);
|
||||
|
||||
$pdf->SetTitle($outputlangs->transnoentities("Payments"));
|
||||
$pdf->SetSubject($outputlangs->transnoentities("Payments"));
|
||||
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
||||
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
|
||||
//$pdf->SetKeyWords();
|
||||
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
||||
|
||||
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
|
||||
$pdf->SetAutoPageBreak(1,0);
|
||||
|
||||
// New page
|
||||
$pdf->AddPage();
|
||||
$pagenb++;
|
||||
$this->_pagehead($pdf, $pagenb, 1, $outputlangs);
|
||||
$pdf->SetFont('','', 9);
|
||||
$pdf->MultiCell(0, 3, ''); // Set interline to 3
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
|
||||
$this->Body($pdf, 1, $lines, $outputlangs);
|
||||
|
||||
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
|
||||
|
||||
$pdf->Close();
|
||||
|
||||
$pdf->Output($file,'F');
|
||||
|
||||
// Add pdfgeneration hook
|
||||
if (! is_object($hookmanager))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager=new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
|
||||
global $action;
|
||||
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show top header of page.
|
||||
*
|
||||
* @param PDF $pdf Object PDF
|
||||
* @param int $page Object to show
|
||||
* @param int $showaddress 0=no, 1=yes
|
||||
* @param Translate $outputlangs Object lang for output
|
||||
* @return void
|
||||
*/
|
||||
function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
// Do not add the BACKGROUND as this is a report
|
||||
//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$title=$conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
$title.=' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
|
||||
$title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true);
|
||||
$pdf->SetFont('','B',$default_font_size + 1);
|
||||
$pdf->SetXY($this->marge_gauche,10);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
|
||||
|
||||
$pdf->SetFont('','',$default_font_size);
|
||||
|
||||
$pdf->SetXY($this->posxdate, 16);
|
||||
$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L');
|
||||
|
||||
$pdf->SetXY($this->posxdate+100, 16);
|
||||
$pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
|
||||
|
||||
|
||||
// Title line
|
||||
$pdf->SetXY($this->posxdate, $this->tab_top+2);
|
||||
$pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
|
||||
|
||||
$pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
|
||||
$pdf->SetXY($this->posxpaymenttype, $this->tab_top+2);
|
||||
$pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
|
||||
|
||||
$pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
|
||||
$pdf->SetXY($this->posxinvoice, $this->tab_top+2);
|
||||
$pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
|
||||
|
||||
$pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
|
||||
$pdf->SetXY($this->posxbankaccount, $this->tab_top+2);
|
||||
$pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');
|
||||
|
||||
|
||||
$pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
|
||||
$pdf->SetXY($this->posxinvoiceamount, $this->tab_top+2);
|
||||
$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
|
||||
|
||||
$pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
|
||||
$pdf->SetXY($this->posxpaymentamount, $this->tab_top+2);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
|
||||
|
||||
$pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
|
||||
|
||||
$pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output body
|
||||
*
|
||||
* @param PDF $pdf PDF object
|
||||
* @param string $page Page
|
||||
* @param array $lines Array of lines
|
||||
* @param Translate $outputlangs Object langs
|
||||
* @return void
|
||||
*/
|
||||
function Body(&$pdf, $page, $lines, $outputlangs)
|
||||
{
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$oldprowid = 0;
|
||||
$pdf->SetFillColor(220,220,220);
|
||||
$yp = 0;
|
||||
$numlines=count($lines);
|
||||
for ($j = 0 ; $j < $numlines ; $j++)
|
||||
{
|
||||
$i = $j;
|
||||
if ($yp > $this->tab_height -5)
|
||||
{
|
||||
$page++;
|
||||
$pdf->AddPage();
|
||||
$this->_pagehead($pdf, $page, 0, $outputlangs);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$yp = 0;
|
||||
}
|
||||
if ($oldprowid <> $lines[$j][7])
|
||||
{
|
||||
if ($yp > $this->tab_height -10)
|
||||
{
|
||||
$page++;
|
||||
$pdf->AddPage();
|
||||
$this->_pagehead($pdf, $page, 0, $outputlangs);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$yp = 0;
|
||||
}
|
||||
|
||||
$pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
|
||||
|
||||
$pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
|
||||
|
||||
$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
|
||||
|
||||
$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
|
||||
$yp = $yp + 5;
|
||||
}
|
||||
|
||||
// Invoice number
|
||||
$pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
|
||||
|
||||
// BankAccount
|
||||
$pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
|
||||
|
||||
// Invoice amount
|
||||
$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
|
||||
|
||||
// Payment amount
|
||||
$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
|
||||
$yp = $yp + 5;
|
||||
|
||||
if ($oldprowid <> $lines[$j][7])
|
||||
{
|
||||
$oldprowid = $lines[$j][7];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -547,6 +547,9 @@ if ($id > 0 || ! empty($ref)) {
|
||||
|
||||
print "\n";
|
||||
print '<!-- Line to dispatch ' . $suffix . ' -->' . "\n";
|
||||
// hidden fields for js function
|
||||
print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $objp->qty . '">';
|
||||
print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched[$objp->rowid] . '">';
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
$linktoprod = '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp->fk_product . '">' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . '</a>';
|
||||
@ -607,9 +610,6 @@ if ($id > 0 || ! empty($ref)) {
|
||||
print '<input class="maxwidth75" name="pu' . $suffix . '" type="hidden" value="' . price2num($up_ht_disc, 'MU') . '">';
|
||||
}
|
||||
|
||||
// hidden fields for js function
|
||||
print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $objp->qty . '">';
|
||||
print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched[$objp->rowid] . '">';
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
@ -649,16 +649,13 @@ if ($id > 0 || ! empty($ref)) {
|
||||
print '<input class="maxwidth75" name="pu' . $suffix . '" type="hidden" value="' . price2num($up_ht_disc, 'MU') . '">';
|
||||
}
|
||||
|
||||
// hidden fields for js function
|
||||
print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $objp->qty . '">';
|
||||
print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched[$objp->rowid] . '">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Qty to dispatch
|
||||
print '<td align="right">';
|
||||
print '<input id="qty' . $suffix . '" name="qty' . $suffix . '" type="text" size="8" value="' . (GETPOST('qty' . $suffix) != '' ? GETPOST('qty' . $suffix) : $remaintodispatch) . '">';
|
||||
print '</td>';
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
|
||||
|
||||
@ -1024,6 +1024,7 @@ while ($i < min($num, $limit))
|
||||
|
||||
$companystatic->id=$obj->rowid;
|
||||
$companystatic->name=$obj->name;
|
||||
$companystatic->name_alias=$obj->name_alias;
|
||||
$companystatic->canvas=$obj->canvas;
|
||||
$companystatic->client=$obj->client;
|
||||
$companystatic->status=$obj->status;
|
||||
@ -1053,7 +1054,6 @@ while ($i < min($num, $limit))
|
||||
}
|
||||
if (! empty($arrayfields['s.name_alias']['checked']))
|
||||
{
|
||||
$companystatic->name_alias=$obj->name_alias; // Added after the getNomUrl
|
||||
print '<td class="tdoverflowmax200">';
|
||||
print $companystatic->name_alias;
|
||||
print "</td>\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user