Merge branch 'develop' into api_rest

Conflicts:
	htdocs/user/card.php
	htdocs/user/class/user.class.php
This commit is contained in:
jfefe 2015-06-15 14:29:34 +02:00
commit 190ee35e86
523 changed files with 11687 additions and 8015 deletions

View File

@ -128,7 +128,7 @@ script:
- php upgrade.php 3.6.0 3.7.0 ignoredbversion > upgrade360370.log
- php upgrade2.php 3.6.0 3.7.0 ignoredbversion > upgrade360370-2.log
- php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log
- cat upgrade370380.log
# - cat upgrade370380.log
- php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log
# - cat upgrade370380-2.log
- cd ../..

View File

@ -41,16 +41,40 @@ Dolibarr better:
- Hooks 'printLeftBlock' and 'formConfirm' are now compliant with hook development rules. They are
"addreplace" hooks, so you must return content with "->resprints='mycontent'" and not with "return 'mycontent'"
- All fields "fk_societe" were renamed into "fk_soc".
- Method select_PriceBaseType and load_PriceBaseType were merged into selectPriceBaseType
***** ChangeLog for 3.7.2 compared to 3.7.1 *****
FIX [ bug #2855 ] Wrong translation key in localtax report page
FIX [ bug #1852 ] JS error when editing a customer order line
FIX [ bug #2900 ] Courtesy title is not stored in create thirdparty form
***** ChangeLog for 3.7.1 compared to 3.7.* *****
- Fix: Bug in the new photo system
- Fix: Error management
- Fix: [ Bug #2714 ] Members -> Memberxy-> Agenda -> technical Error
- Fix: [ Bug #2713 ] 3.7.0 mailing-unsubscribe.php not unsubscribe
FIX Bug in the new photo system
FIX Error management
FIX [ Bug #2714 ] Members -> Memberxy-> Agenda -> technical Error
FIX [ Bug #2713 ] 3.7.0 mailing-unsubscribe.php not unsubscribe
FIX #2901
FIX when we create an agenda event with "Not applicable" status, it is automatically saved with "To do" status
FIX check the user status during authentication
FIX top links menu have target attribute with wrong value
FIX extrafields required on thirdparty
FIX create contact with extrafield is null when it is require
FIX width multiselect
FIX "script" tag with wrong syntax
Fix bug debian 786479
FIX update usergroup name
Fix facturestats was not filtering on invoice type
FIX #2856 : Wrong table design
FIX button create payment hide if tax amount is less than 1
FIX event for restricted user was restricted if company null
FIX send mail, copy sendto don't read the list of contact
FIX Properly escape untrusted data to prevent HTML injection.
FIX send mail, copy sendto don't read the list of contact
- Path to save photos of products was moved in 3.7.0 to match path of other attached files. If you had loose
your photo on the photo tab of products, you can set the constant "PRODUCT_USE_OLD_PATH_FOR_PHOTO" to
restore old path.
Path to save photos of products was moved in 3.7.0 to match path of other attached files. If you had loose
your photo on the photo tab of products, you can set the constant "PRODUCT_USE_OLD_PATH_FOR_PHOTO" to
restore old path.
WARNING:
@ -236,8 +260,8 @@ Dolibarr better:
- Table llx_c_pays were renamed into llx_c_country.
- Triggers *_BUILDDOC are removed. Building a doc is not a business event. For action after
creation of a pdf or odt, hook "afterPDFCreation" or "afterODTCreation" must be used instead.
- A lot of pages called fiche.php were renamed into card.php
- A lot of pages called liste.php were renamed into list.php
- A lot of pages named fiche.php were renamed into card.php
- A lot of pages named liste.php were renamed into list.php
- If you used warehouse/stock module, recheck setup of stock increase/decrease rules of the
warehouse module and your Point Of Sale module setup if you use one.
- Replaced USER_UPDATE_SESSION trigger with an updateSession hook may break modules using it.
@ -279,6 +303,7 @@ Dolibarr better:
- Fix: [ bug #2545 ] Missing object_margin.png in Amarok theme
- Fix: [ bug #2542 ] Contracts store localtax preferences
- Fix: Bad permission assignments for stock movements actions
- Fix: [ bug #2891 ] Category hooks do not work
***** ChangeLog for 3.6.2 compared to 3.6.1 *****
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.
@ -453,6 +478,10 @@ Fix: [ bug #2577 ] Incorrect invoice status in "Linked objects" page of a projec
Fix: [ bug #2576 ] Unable to edit a dictionary entry that has # in its ref
Fix: [ bug #2758 ] Product::update sets product note to "null" when $prod->note is null
Fix: [ bug #2757 ] Deleting product category photo gives "Forbidden access" error
Fix: [ bug #2976 ] "Report" tab is the current tab but it is not marked as selected by the UI
Fix: [ bug #2861 ] Undefined variable $res when migrating
Fix: [ bug #2837 ] Product list table column header does not match column body
Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order
***** ChangeLog for 3.5.6 compared to 3.5.5 *****
Fix: Avoid missing class error for fetch_thirdparty method #1973

View File

@ -455,8 +455,9 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/documents`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/document`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/documents`;
# Removed known external modules to avoir any error when packaging on test env
# Removed known external modules to avoid any error when packaging from env where external modules are tested
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/cabinetmed*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/calling*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/bootstrap*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom*`;
@ -981,10 +982,10 @@ if ($nboftargetok) {
mkdir($DESTI.'/package_windows');
if (-d $DESTI.'/package_windows') { $NEWDESTI=$DESTI.'/package_windows'; }
print "Remove target $FILENAMEEXEDOLIWAMP.exe...\n";
print "Remove target $NEWDESTI/$FILENAMEEXEDOLIWAMP.exe...\n";
unlink "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe";
print "Check that in your Wine setup, you create a Z: drive that point to your /tmp directory.\n";
print "Check that in your Wine setup, you create a Z: drive that point to your / directory.\n";
$SOURCEBACK=$SOURCE;
$SOURCEBACK =~ s/\//\\/g;

View File

@ -8,7 +8,7 @@ This files describe steps made by Dolibarr packaging team to make a
beta version of Dolibarr, step by step.
- Check all files are commited.
- Update version/info in ChangeLog. To generate a changelog, you can do "git log `git merge-base x.y origin/develop`..x.y --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -i -e '^FIX\|NEW'"
- Update version/info in ChangeLog. To generate a changelog, you can do "git log `git merge-base (x.y)-1 origin/develop`..x.y(.z) --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -i -e '^FIX\|NEW'"
- Update version number with x.y.z-w in htdocs/filefunc.inc.php
- Update version number with x.y.z-w in build/debian/changelog
- Commit all changes.
@ -29,7 +29,7 @@ This files describe steps made by Dolibarr packaging team to make a
complete release of Dolibarr, step by step.
- Check all files are commited.
- Update version/info in ChangeLog. To generate a changelog, you can do "git log `git merge-base x.y origin/develop`..x.y --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -i -e '^FIX\|NEW'"
- Update version/info in ChangeLog. To generate a changelog, you can do "git log `git merge-base (x.y)-1 origin/develop`..x.y(.z) --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -i -e '^FIX\|NEW'"
- Update version number with x.y.z in htdocs/filefunc.inc.php
- Update version number with x.y.z in build/debian/changelog
- Commit all changes.

View File

@ -3,7 +3,7 @@
This is a quick tutorial:
* Install ansible:
> apt-get install
> apt-get install ansible
* Add ip of server to manage into
/etc/ansible/hosts

View File

@ -350,6 +350,11 @@
</rule>
<rule ref="PEAR.NamingConventions.ValidVariableName" />
<!-- This is not in PSR2 -->
<rule ref="PEAR.NamingConventions.ValidVariableName.PrivateNoUnderscore">
<severity>0</severity>
</rule>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" />
<!-- Need to be commented to be disabled

View File

@ -49,7 +49,7 @@ then
if [ -d $reflang ]
then
echo "***** Process language "$aa"_"$bb" - Search original into "$reflang
echo $dirshort est une langue alternative de $reflang
echo $dirshort is an alternative language of $reflang
echo ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2
./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2
for fic in `ls htdocs/langs/${aa}_${bb}/*.delta`; do f=`echo $fic | sed -e 's/\.delta//'`; echo $f; mv $f.delta $f; done

View File

@ -0,0 +1,12 @@
# This is an example of multitail setup file you can use to analyze dolibarr log files.
# Usage: multitail -cS dolibarr documents/dolibarr.log
colorscheme:dolibarr
bright:1
cs_re:yellow,red:.*EMERG.*
cs_re:white,red:.*ALERT.*
cs_re:green,red:.*CRIT.*
cs_re:red:.*ERR.*
cs_re:white,yellow:.*WARNING.*
cs_re:green,yellow:.*NOTICE.*
cs_re:green:.*INFO.*
cs_re:white:.*DEBUG.*

View File

@ -167,6 +167,12 @@ class modMyModule extends DolibarrModules
// Example:
//$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>'')););
// Cronjobs
$this->cronjobs = array(); // List of cron jobs entries to add
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600)
// );
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;
@ -180,7 +186,6 @@ class modMyModule extends DolibarrModules
// $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
// $r++;
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;

View File

@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
@ -19,407 +20,463 @@
*/
/**
* \file dev/skeletons/skeleton_class.class.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Put here some comments
* \file dev/skeletons/skeleton_class.class.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Put some comments here
*/
// Put here all includes required by your class file
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
/**
* Put here description of your class
* Class Skeleton_Class
*
* Put here description of your class
*/
class Skeleton_Class extends CommonObject
{
var $db; //!< To store db handler
var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
var $element='skeleton'; //!< Id that identify managed objects
var $table_element='skeleton'; //!< Name of table without prefix where object is stored
/**
* @var DoliDb Database handler
*/
protected $db;
var $lines=array();
/**
* @var string Error code (or message)
* @deprecated
* @see Skeleton_Class::errors
*/
public $error;
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
/**
* @var string Id to identify managed objects
*/
public $element = 'skeleton';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'skeleton';
var $id;
var $prop1;
var $prop2;
/**
* @var Skeleton_ClassLine[] Lines
*/
public $lines = array();
/**
* @var int ID
*/
public $id;
/**
* @var mixed Sample property 1
*/
public $prop1;
/**
* @var mixed Sample property 2
*/
public $prop2;
//...
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
public function __construct( DoliDB $db )
{
$this->db = $db;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
function __construct($db)
{
$this->db = $db;
return 1;
}
return 1;
}
/**
* Create object into database
*
* @param User $user User that creates
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, Id of created object if OK
*/
public function create( User $user, $notrigger = false )
{
dol_syslog( __METHOD__, LOG_DEBUG );
/**
* Create object into database
*
* @param User $user User that creates
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK
*/
function create($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
$error = 0;
// Clean parameters
if (isset($this->prop1)) $this->prop1=trim($this->prop1);
if (isset($this->prop2)) $this->prop2=trim($this->prop2);
if (isset( $this->prop1 )) {
$this->prop1 = trim( $this->prop1 );
}
if (isset( $this->prop2 )) {
$this->prop2 = trim( $this->prop2 );
}
//...
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."(";
$sql.= " field1,";
$sql.= " field2";
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
$sql .= ' field1,';
$sql .= ' field2';
//...
$sql.= ") VALUES (";
$sql.= " '".$this->prop1."',";
$sql.= " '".$this->prop2."'";
$sql .= ') VALUES (';
$sql .= ' \'' . $this->prop1 . '\',';
$sql .= ' \'' . $this->prop2 . '\'';
//...
$sql.= ")";
$sql .= ')';
$this->db->begin();
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
$resql = $this->db->query( $sql );
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
}
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
if (!$error) {
$this->id = $this->db->last_insert_id( MAIN_DB_PREFIX . $this->table_element );
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
//if ($result < 0) $error++;
//// End call triggers
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
//if ($result < 0) $error++;
//// End call triggers
}
}
}
// Commit or rollback
if ($error)
{
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1*$error;
}
else
{
return - 1 * $error;
} else {
$this->db->commit();
return $this->id;
return $this->id;
}
}
}
/**
* Load object in memory from the database
*
* @param int $id Id object
* @param string $ref Ref
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function fetch( $id, $ref = null )
{
dol_syslog( __METHOD__, LOG_DEBUG );
/**
* Load object in memory from the database
*
* @param int $id Id object
* @param string $ref Ref
* @return int <0 if KO, 0 if not found, >0 if OK
*/
function fetch($id,$ref='')
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.field1,";
$sql.= " t.field2";
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= ' t.field1,';
$sql .= ' t.field2';
//...
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
if ($ref) $sql.= " WHERE t.ref = '".$ref."'";
else $sql.= " WHERE t.rowid = ".$id;
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if (null !== $ref) {
$sql .= ' WHERE t.ref = ' . '\'' . $ref . '\'';
} else {
$sql .= ' WHERE t.rowid = ' . $id;
}
dol_syslog(get_class($this)."::fetch");
$resql=$this->db->query($sql);
if ($resql)
{
$numrows = $this->db->num_rows($resql);
if ($numrows)
{
$obj = $this->db->fetch_object($resql);
$resql = $this->db->query( $sql );
if ($resql) {
$numrows = $this->db->num_rows( $resql );
if ($numrows) {
$obj = $this->db->fetch_object( $resql );
$this->id = $obj->rowid;
$this->prop1 = $obj->field1;
$this->prop2 = $obj->field2;
$this->id = $obj->rowid;
$this->prop1 = $obj->field1;
$this->prop2 = $obj->field2;
//...
}
$this->db->free($resql);
}
$this->db->free( $resql );
return ($numrows?1:0);
}
else
{
$this->error="Error ".$this->db->lasterror();
return -1;
}
}
if ($numrows) {
return 1;
} else {
return 0;
}
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
return - 1;
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
*
* @return int <0 if KO, >0 if OK
*/
function fetchAll($sortorder, $sortfield, $limit, $offset, $filter = array())
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.field1,";
$sql.= " t.field2";
//...
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
*/
public function fetchAll( $sortorder, $sortfield, $limit, $offset, array $filter = array() )
{
dol_syslog( __METHOD__, LOG_DEBUG );
// Manage filter
$sqlwhere=array();
if (count($filter)>0) {
foreach ( $filter as $key => $value ) {
//$sqlwhere []= ' AND '. $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
if (count($sqlwhere)>0) {
$sql.= ' WHERE '.implode(' AND ', $sqlwhere);
}
$sql .= " ORDER BY " . $sortfield . " " . $sortorder . " " . $this->db->plimit($limit + 1, $offset);
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= ' t.field1,';
$sql .= ' t.field2';
//...
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'mytable as t';
$this->lines = array ();
// Manage filter
$sqlwhere = array();
if (count( $filter ) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = ' AND ' . $key . ' LIKE \'%' . $this->db->escape( $value ) . '%\'';
}
}
if (count( $sqlwhere ) > 0) {
$sql .= ' WHERE ' . implode( ' AND ', $sqlwhere );
}
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ' ' . $this->db->plimit( $limit + 1, $offset );
dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$this->lines = array();
while ($obj = $this->db->fetch_object($resql))
{
$line=new Skeleton_ClassLine();
$resql = $this->db->query( $sql );
if ($resql) {
$num = $this->db->num_rows( $resql );
$line->id = $obj->rowid;
$line->prop1 = $obj->field1;
$line->prop2 = $obj->field2;
while ($obj = $this->db->fetch_object( $resql )) {
$line = new Skeleton_ClassLine();
$this->lines[]=$line;
//...
}
$this->db->free($resql);
$line->id = $obj->rowid;
$line->prop1 = $obj->field1;
$line->prop2 = $obj->field2;
return $num;
}
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::fetchAll ".$this->error, LOG_ERR);
return -1;
}
}
$this->lines[] = $line;
//...
}
$this->db->free( $resql );
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
/**
* Update object into database
*
* @param User $user User that modifies
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
return - 1;
}
}
/**
* Update object into database
*
* @param User $user User that modifies
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function update( User $user, $notrigger = false )
{
$error = 0;
dol_syslog( __METHOD__, LOG_DEBUG );
// Clean parameters
if (isset($this->prop1)) $this->prop1=trim($this->prop1);
if (isset($this->prop2)) $this->prop2=trim($this->prop2);
if (isset( $this->prop1 )) {
$this->prop1 = trim( $this->prop1 );
}
if (isset( $this->prop2 )) {
$this->prop2 = trim( $this->prop2 );
}
//...
// Check parameters
// Put here code to add a control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql.= " field1=".(isset($this->field1)?"'".$this->db->escape($this->field1)."'":"null").",";
$sql.= " field2=".(isset($this->field2)?"'".$this->db->escape($this->field2)."'":"null")."";
// Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
if (isset( $this->field1 )) {
$sql .= ' field1=\'' . $this->db->escape( $this->field1 ) . '\',';
} else {
$sql .= ' field1=null' . ',';
}
if (isset( $this->field2 )) {
$sql .= ' field2=\'' . $this->db->escape( $this->field2 ) . '\'';
} else {
$sql .= ' field2=null';
}
//...
$sql.= " WHERE rowid=".$this->id;
$sql .= ' WHERE rowid=' . $this->id;
$this->db->begin();
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error && ! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
//// End call triggers
$resql = $this->db->query( $sql );
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
}
// Commit or rollback
if ($error)
{
if (!$error && !$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
//// End call triggers
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1*$error;
}
else
{
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that deletes
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
$this->db->begin();
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
//// End call triggers
}
}
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid=".$this->id;
dol_syslog(__METHOD__);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
}
// Commit or rollback
if ($error)
{
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that deletes
* @param bool $notrigger false=launch triggers after, true=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function delete( User $user, $notrigger = false )
{
dol_syslog( __METHOD__, LOG_DEBUG );
$error = 0;
$this->db->begin();
if (!$error) {
if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
//// End call triggers
}
}
if (!$error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
$sql .= ' WHERE rowid=' . $this->id;
$resql = $this->db->query( $sql );
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Load an object from its id and create a new one in database
* Load an object from its id and create a new one in database
*
* @param int $fromid Id of object to clone
* @return int New id of clone
* @param int $fromid Id of object to clone
*
* @return int New id of clone
*/
function createFromClone($fromid)
public function createFromClone( $fromid )
{
global $user,$langs;
dol_syslog( __METHOD__, LOG_DEBUG );
$error=0;
$object=new Skeleton_Class($this->db);
global $user;
$error = 0;
$object = new Skeleton_Class( $this->db );
$this->db->begin();
// Load source object
$object->fetch($fromid);
$object->id=0;
$object->statut=0;
$object->fetch( $fromid );
// Reset object
$object->id = 0;
// Clear fields
// ...
// Create clone
$result=$object->create($user);
$result = $object->create( $user );
// Other options
if ($result < 0)
{
$this->error=$object->error;
$error++;
}
if (! $error)
{
if ($result < 0) {
$error ++;
$this->errors = $object->errors;
dol_syslog( __METHOD__ . ' ' . join( ',', $this->errors ), LOG_ERR );
}
// End
if (! $error)
{
if (!$error) {
$this->db->commit();
return $object->id;
}
else
{
} else {
$this->db->rollback();
return -1;
return - 1;
}
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
* Initialise object with example values
* Id must be 0 if object instance is a specimen
*
* @return void
* @return void
*/
function initAsSpecimen()
public function initAsSpecimen()
{
$this->id=0;
$this->prop1='prop1';
$this->prop2='prop2';
$this->id = 0;
$this->prop1 = 'prop1';
$this->prop2 = 'prop2';
}
}
/**
* Class Skeleton_ClassLine
*/
class Skeleton_ClassLine
{
var $id;
var $prop1;
var $prop2;
/**
* @var int ID
*/
public $id;
/**
* @var mixed Sample line property 1
*/
public $prop1;
/**
* @var mixed Sample line property 2
*/
public $prop2;
}

View File

@ -352,8 +352,9 @@ if ($id && (empty($action) || $action == 'view'))
// Example 2 : Adding links to objects
// The class must extends CommonObject class to have this method available
//$somethingshown=$object->showLinkedObjectBlock();
//$somethingshown=$form->showLinkedObjectBlock($object);
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
}

View File

@ -314,7 +314,7 @@ foreach($filesToProcess as $fileToProcess)
continue;
}
// String exists in both files and does not match
// String exists in both files and value into alternative language differs from main language but also from english files
if (
(! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
&& ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])

View File

@ -23,12 +23,14 @@
* \brief Card accounting account
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
$error=0;
// Langs
$langs->load("bills");
$langs->load("accountancy");
@ -41,7 +43,7 @@ $rowid = GETPOST('rowid', 'int');
// Security check
if (!$user->admin)
accessforbidden();
$accounting = new AccountingAccount($db);
// Action
@ -49,11 +51,11 @@ if ($action == 'add')
{
if (! GETPOST('cancel', 'alpha')) {
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
$result = $db->query($sql);
$obj = $db->fetch_object($result);
$accounting->fk_pcg_version = $obj->pcg_version;
$accounting->pcg_type = GETPOST('pcg_type');
$accounting->pcg_subtype = GETPOST('pcg_subtype');
@ -61,17 +63,17 @@ if ($action == 'add')
$accounting->account_parent = GETPOST('account_parent', 'int');
$accounting->label = GETPOST('label', 'alpha');
$accounting->active = 1;
$res = $accounting->create($user);
if ($res == 0) {
} else {
if ($res == - 3) {
$_error = 1;
$error = 1;
$action = "create";
}
if ($res == - 4) {
$_error = 2;
$error = 2;
$action = "create";
}
}
@ -82,22 +84,22 @@ else if ($action == 'edit')
{
if (! GETPOST('cancel', 'alpha')) {
$result = $accounting->fetch($id);
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
$result2 = $db->query($sql);
$obj = $db->fetch_object($result2);
$accounting->fk_pcg_version = $obj->pcg_version;
$accounting->pcg_type = GETPOST('pcg_type');
$accounting->pcg_subtype = GETPOST('pcg_subtype');
$accounting->account_number = GETPOST('account_number', 'int');
$accounting->account_parent = GETPOST('account_parent', 'int');
$accounting->label = GETPOST('label', 'alpha');
$result = $accounting->update($user);
if ($result > 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit();
@ -112,15 +114,15 @@ else if ($action == 'edit')
else if ($action == 'delete')
{
$result = $accounting->fetch($id);
if (! empty($accounting->id)) {
$result = $accounting->delete($user);
if ($result > 0) {
Header("Location: account.php");
}
}
if ($result < 0) {
setEventMessage($accounting->error, 'errors');
}
@ -137,7 +139,7 @@ $htmlacc = new FormVentilation($db);
if ($action == 'create')
{
print_fiche_titre($langs->trans('NewAccount'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="add">';
@ -145,7 +147,7 @@ if ($action == 'create')
dol_fiche_head();
print '<table class="border" width="100%">';
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
print '<tr><td>' . $langs->trans("Label") . '</td>';
@ -162,7 +164,7 @@ if ($action == 'create')
print '<td>';
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
print '</td></tr>';
print '</table>';
dol_fiche_end();
@ -172,35 +174,35 @@ if ($action == 'create')
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>';
}
else if ($id)
{
$rowid = $id;
$account = $accounting->fetch($rowid);
if ($account > 0) {
dol_htmloutput_mesg($mesg);
$head = accounting_prepare_head($accounting);
if ($action == 'update')
{
$soc = new Societe($db);
if ($object->socid) {
$soc->fetch($object->socid);
}
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="edit">';
print '<input type="hidden" name="id" value="' . $id . '">';
print '<table class="border" width="100%">';
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
print '<tr><td>' . $langs->trans("Label") . '</td>';
@ -217,7 +219,7 @@ else if ($id)
print '<td>';
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
print '</td></tr>';
print '</table>';
dol_fiche_end();
@ -227,71 +229,71 @@ else if ($id)
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>';
}
else
{
$linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print '<table class="border" width="100%">';
// Account number
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
print '<td>' . $accounting->account_number . '</td>';
print '<td align="right" width="25%">' . $linkback . '</td></tr>';
print '<tr><td>' . $langs->trans("Label") . '</td>';
print '<td colspan="2">' . $accounting->label . '</td></tr>';
$accp = new AccountingAccount($db);
if (! empty($accounting->account_parent)) {
$accp->fetch($accounting->account_parent, '');
}
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<td colspan="2">' . $accp->account_number . ' - ' . $accp->label . '</td></tr>';
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<td colspan="2">' . $accounting->pcg_type . '</td></tr>';
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td colspan="2">' . $accounting->pcg_subtype . '</td></tr>';
print '<tr><td>' . $langs->trans("Active") . '</td>';
print '<td colspan="2">';
if (empty($accounting->active)) {
print img_picto($langs->trans("Disabled"), 'switch_off');
} else {
print img_picto($langs->trans("Activated"), 'switch_on');
}
print '</td></tr>';
print '</table>';
dol_fiche_end();
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($user->admin) {
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
} else {
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Modify') . '</a>';
}
if ($user->admin) {
print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
} else {
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Delete') . '</a>';
}
print '</div>';
}
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.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
@ -205,36 +205,42 @@ if ($action == 'create') {
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
dol_fiche_head();
print '<table class="border" width="100%">';
print '<tr class="pair">';
print '<tr>';
print '<td>' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $next_num_mvt . '</td>';
print '</tr>';
print '<tr class="impair">';
print '<tr>';
print '<td>' . $langs->trans("Docdate") . '</td>';
print '<td>';
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>';
print '</tr>';
print '<tr class="pair">';
print '<tr>';
print '<td>' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>';
print '</tr>';
print '<tr class="impair">';
print '<tr>';
print '<td>' . $langs->trans("Docref") . '</td>';
print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
print '</tr>';
print '<tr class="pair">';
print '<tr>';
print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
print '</tr>';
print '</table>';
print '<br>';
print '<input type="submit" class="butAction" value="' . $langs->trans("Save") . '">';
dol_fiche_end();
print '<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="'.$langs->trans("Cancel").'" class="button" onclick="history.go(-1)" />';
print '</div>';
print '</form>';
}
else

View File

@ -1,7 +1,7 @@
<?PHP
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.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
@ -44,7 +44,6 @@ if ($user->societe_id > 0)
/*
* Actions
*/
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
if (! GETPOST('cancel', 'alpha'))
{
@ -63,6 +62,10 @@ if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
}
}
/*
* View
*/
llxHeader("", "", "FicheVentilation");
if ($cancel == $langs->trans("Cancel")) {
@ -108,6 +111,8 @@ if (! empty($id)) {
$linkback='<a href="'.DOL_URL_ROOT.'/accountancy/customer/lines.php">'.$langs->trans("Back").'</a>';
print_fiche_titre($langs->trans('CustomersVentilation'),$linkback,'title_setup');
dol_fiche_head();
print '<table class="border" width="100%">';
// Ref facture
@ -120,13 +125,13 @@ if (! empty($id)) {
print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
print '<td>' . nl2br($objp->description) . '</td></tr>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print $objp->account_number . '-' . $objp->label;
print '<tr><td width="20%">' . $langs->trans("NewAccount") . '</td><td>';
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<br><div class="center">';
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
@ -144,4 +149,4 @@ if (! empty($id)) {
}
llxFooter();
$db->close();
$db->close();

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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
@ -172,8 +172,8 @@ if ($resql) {
while ( $i < $num ) {
$row = $db->fetch_row($resql);
print '<tr><td>' . length_accountg($row[0]) . '</td>';
$var=!$var;
print '<tr '.$bc[$var].'><td>' . length_accountg($row[0]) . '</td>';
print '<td align="left">' . $row[1] . '</td>';
print '<td align="right">' . price($row[2]) . '</td>';
print '<td align="right">' . price($row[3]) . '</td>';

View File

@ -43,7 +43,7 @@ $search_facture = GETPOST('search_facture','alpha');
$search_label = GETPOST('search_label','alpha');
$search_desc = GETPOST('search_desc','alpha');
$search_amount = GETPOST('search_amount','alpha');
$search_acount = GETPOST('search_account','alpha');
$search_account = GETPOST('search_account','alpha');
// Security check
if ($user->societe_id > 0)

View File

@ -555,9 +555,9 @@ else
$h=0;
$head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal;
$head[$h][1] = $langs->trans("Report");
$head[$h][2] = 'report';
$head[$h][2] = 'card';
dol_fiche_head($head, $hselected);
dol_fiche_head($head, 'card', $langs->trans("BankJournal"), 0, 'payment');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal.'">';
print '<table width="100%" class="border">';

View File

@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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
@ -34,31 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$action = GETPOST('action');
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$codeventil = GETPOST('codeventil');
$id = GETPOST('id');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch)
{
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
dol_syslog('accountancy/journal/sellsjournal.php:: $sql=' . $sql);
$resql = $db->query($sql);
if (! $resql) {
setEventMessage($db->lasterror(), 'errors');
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
if (! GETPOST('cancel', 'alpha'))
{
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
dol_syslog('accountancy/supplier/card.php:: $sql=' . $sql);
$resql = $db->query($sql);
if (! $resql) {
setEventMessage($db->lasterror(), 'errors');
}
} else {
header("Location: ./lines.php");
exit();
}
}
@ -78,7 +79,7 @@ $form = new Form($db);
$facturefournisseur_static = new FactureFournisseur($db);
$formventilation = new FormVentilation($db);
if ($_GET["id"]) {
if (! empty($id)) {
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label";
$sql .= ", aa.account_number, aa.label";
@ -87,11 +88,14 @@ if ($_GET["id"]) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
}
dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
@ -103,7 +107,10 @@ if ($_GET["id"]) {
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="ventil">';
print_fiche_titre($langs->trans("SuppliersVentilation"));
$linkback='<a href="'.DOL_URL_ROOT.'/accountancy/supplier/lines.php">'.$langs->trans("Back").'</a>';
print_fiche_titre($langs->trans('SuppliersVentilation'),$linkback,'title_setup');
dol_fiche_head();
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
@ -119,19 +126,24 @@ if ($_GET["id"]) {
print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print $objp->account_number . '-' . $objp->label;
print '<tr><td width="20%">' . $langs->trans("NewAccount") . '</td><td>';
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" class="button" value="' . $langs->trans("Update") . '"></td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>';
} else {
print "Error 1";
print "Error";
}
} else {
print "Error 2";
print "Error";
}
} else {
print "Error ID incorrect";

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -158,8 +158,8 @@ if ($resql) {
while ( $i < $num ) {
$row = $db->fetch_row($resql);
print '<tr><td>' . length_accountg($row[0]) . '</td>';
$var=!$var;
print '<tr '.$bc[$var].'><td>' . length_accountg($row[0]) . '</td>';
print '<td align="left">' . $row[1] . '</td>';
print '<td align="right">' . price($row[2]) . '</td>';
print '<td align="right">' . price($row[3]) . '</td>';

View File

@ -44,7 +44,7 @@ $search_facture = GETPOST('search_facture','alpha');
$search_label = GETPOST('search_label','alpha');
$search_desc = GETPOST('search_desc','alpha');
$search_amount = GETPOST('search_amount','alpha');
$search_acount = GETPOST('search_account','alpha');
$search_account = GETPOST('search_account','alpha');
// Security check
if ($user->societe_id > 0)

View File

@ -55,6 +55,8 @@ abstract class ActionsAdherentCardCommon
*/
private function getInstanceDao()
{
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
if (! is_object($this->object))
{
$modelclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/dao_'.$this->targetmodule.'_'.$this->canvas.'.class.php');

View File

@ -1045,7 +1045,7 @@ else
{
if ($object->photo) print "<br>\n";
print '<table class="nobordernopadding">';
if ($object->photo) print '<tr><td align="center"><input type="checkbox" class="flat" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
if ($object->photo) print '<tr><td align="center"><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
print '</table>';

View File

@ -39,7 +39,6 @@ class AdherentType extends CommonObject
/**
* @var int
* @deprecated Use rowid
*/
public $ref;

View File

@ -107,7 +107,7 @@ if ($sall)
foreach ($scrit as $crit)
{
$sql.=" AND (";
if (is_numeric($sall)) $sql.= "d.rowid = ".$sall." OR ";
if (is_numeric($sall)) $sql.= "d.rowid = ".$db->escape($sall)." OR ";
$sql.=" d.firstname LIKE '%".$db->escape($sall)."%' OR d.lastname LIKE '%".$db->escape($sall)."%' OR d.societe LIKE '%".$db->escape($sall)."%'";
$sql.=" OR d.email LIKE '%".$db->escape($sall)."%' OR d.login LIKE '%".$db->escape($sall)."%' OR d.address LIKE '%".$db->escape($sall)."%'";
$sql.=" OR d.town LIKE '%".$db->escape($sall)."%' OR d.note_public LIKE '%".$db->escape($sall)."%' OR d.note_private LIKE '%".$db->escape($sall)."%')";
@ -115,7 +115,7 @@ if ($sall)
}
if ($type > 0)
{
$sql.=" AND t.rowid=".$type;
$sql.=" AND t.rowid=".$db->escape($type);
}
if (isset($_GET["statut"]) || isset($_POST["statut"]))
{

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.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
@ -151,6 +152,7 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
dolibarr_set_const($db, "MAIN_INFO_PROFID6",$_POST["MAIN_INFO_PROFID6"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT",$_POST["object"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START",$_POST["fiscalmonthstart"],'chaine',0,'',$conf->entity);
@ -383,7 +385,7 @@ if ($action == 'edit' || $action == 'updateedit')
}
else
{
print '<img height="30" src="'.DOL_URL_ROOT.'/theme/common/nophoto.jpg">';
print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.jpg">';
}
print '</td></tr></table>';
print '</td></tr>';
@ -420,7 +422,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '<tr '.$bc[$var].'><td><label for="legal_form">'.$langs->trans("JuridicalStatus").'</label></td><td>';
if ($mysoc->country_code)
{
print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$mysoc->country_code);
print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE, $mysoc->country_code, '', 'legal_form');
}
else
{
@ -528,6 +530,12 @@ if ($action == 'edit' || $action == 'updateedit')
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
print '<input name="tva" id="intra_vat" size="20" value="' . (! empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '') . '">';
print '</td></tr>';
// Object of the company
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="object">'.$langs->trans("CompanyObject").'</label></td><td>';
print '<textarea class="flat" name="object" id="object" cols="80" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
print '</td></tr>';
print '</table>';
@ -769,7 +777,7 @@ else
}
else
{
print '<img height="30" src="'.DOL_URL_ROOT.'/theme/common/nophoto.jpg">';
print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.jpg">';
}
print '</td></tr></table>';
@ -929,6 +937,9 @@ else
}
print '</td>';
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%" valign="top">'.$langs->trans("CompanyObject").'</td><td>' . (! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? nl2br($conf->global->MAIN_INFO_SOCIETE_OBJECT) : '') . '</td></tr>';
print '</table>';
print '</form>';

View File

@ -70,7 +70,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,10,23,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,0,25,0,26);
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,10,23,12,13,0,14,0,7,17,24,0,22,20,18,21,0,15,0,25,0,26);
// Name of SQL tables of dictionaries
$tabname=array();
@ -832,7 +832,7 @@ if ($id)
$fieldlist=explode(',',$tabfield[$id]);
// Line for title
print '<tr class="liste_titre">';
print '<tr class="liste_titre nohover">';
foreach ($fieldlist as $field => $value)
{
// Determine le nom du champ par rapport aux noms possibles

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
@ -78,10 +78,13 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", $_POST["MAIN_HELP_DISABLELINK"],'chaine',0,'',0); // Param for all entities
dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", $_POST["MAIN_BUGTRACK_ENABLELINK"],'chaine',0,'',$conf->entity);
if (GETPOST('check_THEME_ELDY_USE_HOVER') == 'on') dolibarr_set_const($db,"THEME_ELDY_USE_HOVER", 1,'chaine',0,'',$conf->entity);
else dolibarr_set_const($db,"THEME_ELDY_USE_HOVER",0,'chaine',0,'',$conf->entity);
// This one is not always defined
if (isset($_POST["MAIN_USE_PREVIEW_TABS"])) dolibarr_set_const($db, "MAIN_USE_PREVIEW_TABS", $_POST["MAIN_USE_PREVIEW_TABS"],'chaine',0,'',$conf->entity);
if (isset($_POST["MAIN_BUGTRACK_ENABLELINK"])) dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", $_POST["MAIN_BUGTRACK_ENABLELINK"],'chaine',0,'',$conf->entity);
$_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer
@ -279,22 +282,19 @@ if ($action == 'edit') // Edit
print '<td width="20">&nbsp;</td>';
print '</tr>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || ! empty($conf->global->MAIN_BUGTRACK_ENABLELINK))
{
// Show bugtrack link
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK',$conf->global->MAIN_BUGTRACK_ENABLELINK,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
}
// Show bugtrack link
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK',$conf->global->MAIN_BUGTRACK_ENABLELINK,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Message on login page
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, 90);
$doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor->Create();
print '</td></tr>'."\n";
@ -303,7 +303,7 @@ if ($action == 'edit') // Edit
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, 90);
$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor->Create();
print '</td></tr>'."\n";
@ -465,15 +465,12 @@ else // Show
print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
print '</td></tr>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 1 || ! empty($conf->global->MAIN_BUGTRACK_ENABLELINK))
{
// Show bugtrack link
$var=!$var;
print '<tr '.$bc[$var].'"><td width="35%">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)."</td>";
print '<td width="20">&nbsp;</td>';
print "</tr>";
}
// Show bugtrack link
$var=!$var;
print '<tr '.$bc[$var].'"><td width="35%">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)."</td>";
print '<td width="20">&nbsp;</td>';
print "</tr>";
// Message login
$var=!$var;

View File

@ -121,7 +121,7 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml']))
$pathtodelete=$listofpaths[$keytodelete];
$filetodelete=$listofnames[$keytodelete];
$result = dol_delete_file($pathtodelete,1);
if ($result >= 0)
if ($result)
{
setEventMessage($langs->trans("FileWasRemoved"), $filetodelete);

View File

@ -5,7 +5,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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

View File

@ -53,7 +53,9 @@ print '<br><br>';
// Show logo
print '<div class="center"><div class="logo_setup"></div></div>';
//print '<div class="center"><div class="logo_setup"></div></div>';
print '<center><div class="logo_setup"></div></center>'; // For a reason I don't know, the div class="center does not works, we must keep the <center>
llxFooter();
$db->close();

View File

@ -89,7 +89,7 @@ if ($action=='purge' && ! preg_match('/^confirm/i',$choice) && ($choice != 'allf
// If (file that is not logfile) or (if logfile with option logfile)
if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile')
{
$count+=dol_delete_file($filesarray[$key]['fullname']);
$count+=(dol_delete_file($filesarray[$key]['fullname'])?1:0);
}
}
}

View File

@ -22,24 +22,24 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
/**
* Class for API
*
*
*/
class DolibarrApi
{
/**
* @var DoliDb $db Database object
*/
static protected $db;
/**
* @var Restler $r Restler object
*/
var $r;
/**
* Constructor
*
*
* @param DoliDb $db Database handler
*/
function __construct($db) {
@ -51,7 +51,7 @@ class DolibarrApi
* Executed method when API is called without parameter
*
* Display a short message an return a http code 200
*
*
* @return array
*/
function index()
@ -67,10 +67,10 @@ class DolibarrApi
/**
* Clean sensible object datas
*
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*
*
* @todo use an array for properties to clean
*
*/
@ -78,14 +78,16 @@ class DolibarrApi
// Remove $db object property for object
unset($object->db);
// If object has lines, remove $db property
if(isset($object->lines) && count($object->lines) > 0) {
for($i=0; $i < count($object->lines); $i++) {
$nboflines = count($object->lines);
for ($i=0; $i < $nbofline; $i++)
{
$this->_cleanObjectDatas($object->lines[$i]);
}
}
// If object has linked objects, remove $db property
if(isset($object->linkedObjects) && count($object->linkedObjects) > 0) {
foreach($object->linkedObjects as $type_object => $linked_object) {
@ -96,12 +98,12 @@ class DolibarrApi
}
return $object;
}
/**
* Check user access to a resource
*
*
* Check access by user to a given resource
*
*
* @param string $resource element to check
* @param int $resource_id Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
* @param type $dbtablename 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)
@ -111,18 +113,18 @@ class DolibarrApi
* @throws RestException
*/
static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') {
// Features/modules to check
$featuresarray = array($resource);
if (preg_match('/&/', $resource)) {
$featuresarray = explode("&", $resource);
if (preg_match('/&/', $resource)) {
$featuresarray = explode("&", $resource);
}
else if (preg_match('/\|/', $resource)) {
$featuresarray = explode("|", $resource);
else if (preg_match('/\|/', $resource)) {
$featuresarray = explode("|", $resource);
}
// More subfeatures to check
if (! empty($feature2)) {
if (! empty($feature2)) {
$feature2 = explode("|", $feature2);
}
@ -141,18 +143,18 @@ class DolibarrApiInit extends DolibarrApi
global $db;
$this->db = $db;
}
/**
* Login
*
*
* Log user with username and password
*
*
* @param string $login Username
* @param string $password User password
* @param int $entity User entity
* @return array Response status and user token
*
* @throws RestException
*
* @throws RestException
*/
public function login($login, $password, $entity = 0) {
@ -171,22 +173,22 @@ class DolibarrApiInit extends DolibarrApi
{
throw new RestException(403, 'Access denied');
}
// Generate token for user
$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1);
// We store API token into database
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql.= " SET api_key = '".$this->db->escape($token)."'";
$sql.= " WHERE login = '".$this->db->escape($login)."'";
dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log
$result = $this->db->query($sql);
if (!$result)
{
throw new RestException(500, 'Error when updating user :'.$this->db->error_msg);
}
//return token
return array(
'success' => array(
@ -199,7 +201,7 @@ class DolibarrApiInit extends DolibarrApi
/**
* Get status (Dolibarr version)
*
*
* @access protected
* @class DolibarrApiAccess {@requires admin}
*/

View File

@ -18,7 +18,7 @@
use \Luracast\Restler\iAuthenticate;
use \Luracast\Restler\Resources;
use \Luracast\Restler\Defaults;
use Luracast\Restler\RestException;
use \Luracast\Restler\RestException;
/**
@ -46,22 +46,14 @@ class DolibarrApiAccess implements iAuthenticate
// @codingStandardsIgnoreStart
/**
* @return string string to be used with WWW-Authenticate header
* @example Basic
* @example Digest
* @example OAuth
*/
public function __getWWWAuthenticateString();
/**
* Check access
*
* @return boolean
* @return bool
* @throws RestException
*/
public function _isAllowed()
{
// @codingStandardsIgnoreEnd
{
global $db;
$stored_key = '';
@ -74,7 +66,8 @@ class DolibarrApiAccess implements iAuthenticate
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.api_key = '".$db->escape($_GET['api_key'])."'";
if ($db->query($sql))
$result = $db->query($sql);
if ($result)
{
if ($db->num_rows($result))
{
@ -115,20 +108,26 @@ class DolibarrApiAccess implements iAuthenticate
return in_array(static::$role, (array) static::$requires) || static::$role == 'admin';
}
// @codingStandardsIgnoreStart
public function __getWWWAuthenticateString()
/**
* @return string string to be used with WWW-Authenticate header
* @example Basic
* @example Digest
* @example OAuth
*/
public function _getWWWAuthenticateString()
{
return '';
}
// @codingStandardsIgnoreEnd
/**
* Verify access
*
* @param array $m Properties of method
*
* @access private
*/
* Verify access
*
* @param array $m Properties of method
*
* @access private
* @return bool
*/
public static function verifyAccess(array $m)
{
$requires = isset($m['class']['DolibarrApiAccess']['properties']['requires'])

View File

@ -102,7 +102,7 @@ print "</tr>\n";
$var=!$var;
print '<tr '.$bc[$var].'><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
print '<td colspan="2">';
print $form->select_thirdparty($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3)',0,array(),1);
print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3)',1,0,1,array(),0);
print '</td></tr>';
if (! empty($conf->banque->enabled))
{
@ -133,17 +133,17 @@ if (! empty($conf->stock->enabled))
if (empty($conf->productbatch->enabled)) {
print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK',$conf->global->CASHDESK_NO_DECREASE_STOCK,1);
}
else
else
{
if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
$res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",1,'chaine',0,'',$conf->entity);
}
print $langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch');
print $langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch');
}
print '</td></tr>';
$disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK;
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
print '<td colspan="2">';

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2015 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
@ -41,8 +42,10 @@ require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
//header("Content-type: text/html; charset=UTF-8");
header("Content-type: text/html; charset=".$conf->file->character_set_client);
$search = GETPOST("code", "alpha");
// Search from criteria
if (dol_strlen($_GET["code"]) >= 0) // If search criteria is on char length at least
if (dol_strlen($search) >= 0) // If search criteria is on char length at least
{
$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
@ -54,11 +57,15 @@ if (dol_strlen($_GET["code"]) >= 0) // If search criteria is on char length at l
// Add criteria on ref/label
if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
{
$sql.= " AND (p.ref LIKE '".$_GET['code']."%' OR p.label LIKE '".$_GET['code']."%')";
$sql.= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'";
if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$db->escape($search)."%'";
$sql.= ")";
}
else
{
$sql.= " AND (p.ref LIKE '%".$_GET['code']."%' OR p.label LIKE '%".$_GET['code']."%')";
$sql.= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'";
if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '%".$db->escape($search)."%'";
$sql.= ")";
}
$sql.= " ORDER BY label";

View File

@ -1,5 +1,6 @@
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2015 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
@ -59,8 +60,8 @@ function afficheDonnees(aId, aTexte) {
// aCible : id du bloc de destination; aCode : argument a passer a la page php chargee du traitement et de l'affichage
function verifResultat(aCible, aCode) {
if (aCode != '') {
function verifResultat(aCible, aCode, iLimit = 1) {
if (aCode != '' && aCode.length >= iLimit) {
if (texte = file ('facturation_dhtml.php?code='+escape(aCode))) {

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 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
@ -43,8 +44,8 @@ $langs->load("cashdesk");
<!-- Affichage de la reference et de la designation -->
<td><input class="texte_ref" type="text" id ="txtRef" name="txtRef" value="<?php echo $obj_facturation->ref() ?>"
onchange="javascript: setSource('REF');"
onkeyup="javascript: verifResultat('resultats_dhtml', this.value);"
onfocus="javascript: this.select(); verifResultat('resultats_dhtml', this.value);"
onkeyup="javascript: verifResultat('resultats_dhtml', this.value, <?php echo (isset($conf->global->BARCODE_USE_SEARCH_TO_SELECT) ? (int) $conf->global->BARCODE_USE_SEARCH_TO_SELECT : 1) ?>);"
onfocus="javascript: this.select(); verifResultat('resultats_dhtml', this.value, <?php echo (isset($conf->global->BARCODE_USE_SEARCH_TO_SELECT) ? (int) $conf->global->BARCODE_USE_SEARCH_TO_SELECT : 1) ?>);"
onBlur="javascript: document.getElementById('resultats_dhtml').innerHTML = '';"/>
</td>
<td class="select_design">

View File

@ -65,6 +65,10 @@ $object = new Categorie($db);
$extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
/*
* Actions
*/

View File

@ -208,7 +208,7 @@ if (empty($reshook))
}
else
{
setEventMessages($cat->error,$this->errors,'errors');
setEventMessages( $cat->error, $cat->errors, 'errors' );
}
}
}

View File

@ -48,6 +48,67 @@ class Categorie extends CommonObject
const TYPE_MEMBER = 3;
const TYPE_CONTACT = 4;
/**
* @var array ID mapping from type string
*
* @note Move to const array when PHP 5.6 will be our minimum target
*/
private $MAP_ID = array(
'product' => 0,
'supplier' => 1,
'customer' => 2,
'member' => 3,
'contact' => 4,
);
/**
* @var array Foreign keys mapping from type string
*
* @note Move to const array when PHP 5.6 will be our minimum target
*/
private $MAP_CAT_FK = array(
'product' => 'product',
'customer' => 'soc',
'supplier' => 'soc',
'member' => 'member',
'contact' => 'socpeople',
);
/**
* @var array Category tables mapping from type string
*
* @note Move to const array when PHP 5.6 will be our minimum target
*/
private $MAP_CAT_TABLE = array(
'product' => 'product',
'customer' => 'societe',
'supplier' => 'fournisseur',
'member' => 'member',
'contact' => 'contact',
);
/**
* @var array Object class mapping from type string
*
* @note Move to const array when PHP 5.6 will be our minimum target
*/
private $MAP_OBJ_CLASS = array(
'product' => 'Product',
'customer' => 'Societe',
'supplier' => 'Fournisseur',
'member' => 'Adherent',
'contact' => 'Contact',
);
/**
* @var array Object table mapping from type string
*
* @note Move to const array when PHP 5.6 will be our minimum target
*/
private $MAP_OBJ_TABLE = array(
'product' => 'product',
'customer' => 'societe',
'supplier' => 'societe',
'member' => 'adherent',
'contact' => 'socpeople',
);
public $element='category';
public $table_element='categories';
@ -56,13 +117,21 @@ class Categorie extends CommonObject
var $label;
var $description;
var $socid;
var $type; // 0=Product, 1=Supplier, 2=Customer/Prospect, 3=Member, 4=Contact
/**
* @var int Category type
*
* @see Categorie::TYPE_PRODUCT
* @see Categorie::TYPE_SUPPLIER
* @see Categorie::TYPE_CUSTOMER
* @see Categorie::TYPE_MEMBER
* @see Categorie::TYPE_CONTACT
*/
var $type;
var $import_key;
var $cats=array(); // Tableau en memoire des categories
var $motherof=array();
/**
* Constructor
*
@ -477,11 +546,12 @@ class Categorie extends CommonObject
}
/**
* Link an object to the category
* Link an object to the category
*
* @param Object $obj Object to link to category
* @param string $type Type of category ('societe', 'member', 'product', 'contact', 'fournisseur)
* @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked
* @param CommonObject $obj Object to link to category
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
*
* @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked
*/
function add_type($obj,$type)
{
@ -492,28 +562,21 @@ class Categorie extends CommonObject
if ($this->id == -1) return -2;
// For backward compatibility
if ($type == 'company') $type='societe';
elseif ($type == 'customer') $type='societe';
elseif ($type == 'supplier') $type='fournisseur';
/**
* llx_categorie_contact => fk_socpeople
* llx_categorie_fournisseur, llx_categorie_societe => fk_soc
* llx_categorie_member => fk_member
* llx_categorie_product => fk_product
*/
if ($type == 'contact') {
$column_name = 'socpeople';
} elseif ($type == 'fournisseur' || ($type == 'societe')) {
$column_name = 'soc';
} else {
$column_name = $type;
if ($type == 'societe') {
$type = 'customer';
dol_syslog( get_class( $this ) . "::add_type(): type 'societe' is deprecated, please use 'customer' instead",
LOG_WARNING );
} elseif ($type == 'fournisseur') {
$type = 'supplier';
dol_syslog( get_class( $this ) . "::add_type(): type 'fournisseur' is deprecated, please use 'supplier' instead",
LOG_WARNING );
}
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$column_name.")";
$sql .= " VALUES (".$this->id.", ".$obj->id.")";
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type];
$sql .= " (fk_categorie, fk_" . $this->MAP_CAT_FK[$type] . ")";
$sql .= " VALUES (" . $this->id . ", " . $obj->id . ")";
dol_syslog(get_class($this).'::add_type', LOG_DEBUG);
if ($this->db->query($sql))
@ -596,9 +659,10 @@ class Categorie extends CommonObject
/**
* Delete object from category
*
* @param Object $obj Object
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @return int 1 if OK, -1 if KO
* @param CommonObject $obj Object
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
*
* @return int 1 if OK, -1 if KO
*/
function del_type($obj,$type)
{
@ -607,19 +671,21 @@ class Categorie extends CommonObject
$error=0;
// For backward compatibility
if ($type == 'company') $type='societe';
if ($type == 'customer') $type='societe';
if ($type == 'supplier') $type='fournisseur';
$column_name=$type;
if ($type=='contact') $column_name='socpeople';
if ($type=='fournisseur') $column_name='societe';
if ($type == 'societe') {
$type = 'customer';
dol_syslog( get_class( $this ) . "::del_type(): type 'societe' is deprecated, please use 'customer' instead",
LOG_WARNING );
} elseif ($type == 'fournisseur') {
$type = 'supplier';
dol_syslog( get_class( $this ) . "::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead",
LOG_WARNING );
}
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type;
$sql .= " WHERE fk_categorie = ".$this->id;
$sql .= " AND fk_".$column_name." = ".$obj->id;
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type];
$sql .= " WHERE fk_categorie = " . $this->id;
$sql .= " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $obj->id;
dol_syslog(get_class($this).'::del_type', LOG_DEBUG);
if ($this->db->query($sql))
@ -652,41 +718,32 @@ class Categorie extends CommonObject
}
/**
* Return list of fetched instance of elements having this category
* Return list of fetched instance of elements having this category
*
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @return mixed -1 if KO, array of instance of object if OK
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
*
* @return mixed -1 if KO, array of instance of object if OK
*/
function getObjectsInCateg($type)
{
$field=''; $classname=''; $category_table=''; $object_table='';
if ($type=='product') { $field='product'; $classname='Product'; }
if ($type=='customer') { $field='soc'; $classname='Societe'; $category_table='societe'; $object_table='societe'; }
if ($type=='supplier') { $field='soc'; $classname='Fournisseur'; $category_table='fournisseur'; $object_table='societe'; }
if ($type=='member') { $field='member'; $classname='Adherent'; $category_table=''; $object_table='adherent'; }
if ($type=='contact') { $field='socpeople'; $classname='Contact'; $category_table='contact'; $object_table='socpeople'; }
$objs = array();
// Clean parameters
if (empty($category_table)) $category_table=$field;
if (empty($object_table)) $object_table=$field;
$obj = new $this->MAP_OBJ_CLASS[$type]( $this->db );
$sql = "SELECT c.fk_".$field;
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$category_table." as c";
$sql.= ", ".MAIN_DB_PREFIX.$object_table." as o";
$sql.= " WHERE o.entity IN (".getEntity($field, 1).")";
$sql = "SELECT c.fk_" . $this->MAP_CAT_FK[$type];
$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c";
$sql .= ", " . MAIN_DB_PREFIX . $this->MAP_OBJ_TABLE[$type] . " as o";
$sql .= " WHERE o.entity IN (" . getEntity( $obj->element, 1).")";
$sql.= " AND c.fk_categorie = ".$this->id;
$sql.= " AND c.fk_".$field." = o.rowid";
$sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid";
dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
while ($rec = $this->db->fetch_array($resql))
{
$obj = new $classname($this->db);
$obj->fetch($rec['fk_'.$field]);
while ($rec = $this->db->fetch_array($resql)) {
$obj = new $this->MAP_OBJ_CLASS[$type]( $this->db );
$obj->fetch( $rec['fk_' . $this->MAP_CAT_FK[$type]]);
$objs[] = $obj;
}
return $objs;
@ -699,40 +756,17 @@ class Categorie extends CommonObject
}
/**
* check for the presence of an object in a category
* Check for the presence of an object in a category
*
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @param int $object_id id of the object to search
* @return int number of occurrences
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
* @param int $object_id id of the object to search
*
* @return int number of occurrences
*/
function containsObject($type, $object_id)
function containsObject($type, $object_id )
{
$field = '';
$category_table = '';
if ($type == 'product') {
$field = 'product';
}
if ($type == 'customer') {
$field = 'societe';
}
if ($type == 'supplier') {
$field = 'societe';
$category_table = 'fournisseur';
}
if ($type == 'member') {
$field = 'member';
$category_table = '';
}
if ($type == 'contact') {
$field = 'socpeople';
$category_table = 'contact';
}
if (empty($category_table)) {
$category_table = $field;
}
$sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $category_table;
$sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $field . " = " . $object_id;
$sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type];
$sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $object_id;
dol_syslog(get_class($this)."::containsObject", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
@ -772,7 +806,6 @@ class Categorie extends CommonObject
}
}
/**
* Load this->motherof that is array(id_son=>id_parent, ...)
*
@ -808,23 +841,34 @@ class Categorie extends CommonObject
}
/**
* Reconstruit l'arborescence des categories sous la forme d'un tableau
* Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec:
* id = id de la categorie
* id_mere = id de la categorie mere
* id_children = tableau des id enfant
* label = nom de la categorie
* fulllabel = nom avec chemin complet de la categorie
* fullpath = chemin complet compose des id
* Reconstruit l'arborescence des categories sous la forme d'un tableau
* Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec:
* id = id de la categorie
* id_mere = id de la categorie mere
* id_children = tableau des id enfant
* label = nom de la categorie
* fulllabel = nom avec chemin complet de la categorie
* fullpath = chemin complet compose des id
*
* @param string $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members)
* @param int $markafterid Removed all categories including the leaf $markafterid in category tree.
* @return array Array of categories. this->cats and this->motherof are set.
* @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member'). Old
* mode (0, 1, 2, ...) is deprecated.
* @param int $markafterid Removed all categories including the leaf $markafterid in category tree.
*
* @return array Array of categories. this->cats and this->motherof are set.
*/
function get_full_arbo($type,$markafterid=0)
{
global $conf, $langs;
// For backward compatibility
if (is_numeric( $type )) {
// We want to reverse lookup
$map_type = array_flip( $this->MAP_ID );
$type = $map_type[$type];
dol_syslog( get_class( $this ) . "::get_full_arbo(): numeric types are deprecated, please use string instead",
LOG_WARNING );
}
$this->cats = array();
// Init this->motherof that is array(id_son=>id_parent, ...)
@ -836,8 +880,8 @@ class Categorie extends CommonObject
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ", t.label as label_trans, t.description as description_trans";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c";
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'";
$sql.= " WHERE c.entity IN (".getEntity('category',1).")";
$sql.= " AND c.type = ".$type;
$sql .= " WHERE c.entity IN (" . getEntity( 'category', 1 ) . ")";
$sql .= " AND c.type = " . $this->MAP_ID[$type];
dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -1171,37 +1215,35 @@ class Categorie extends CommonObject
}
/**
* Return list of categories (id or instances) linked to element of id $id and type $type
* Should be named getListOfCategForObject
* Return list of categories (object instances or labels) linked to element of id $id and type $type
* Should be named getListOfCategForObject
*
* @param int $id Id of element
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated.
* @param string $mode 'object'=Get array of fetched category instances, 'label'=Get array of category labels
* @return mixed Array of category objects or < 0 if KO
* @param int $id Id of element
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode
* (0, 1, 2, ...) is deprecated.
* @param string $mode 'object'=Get array of fetched category instances, 'label'=Get array of category
* labels
*
* @return mixed Array of category objects or < 0 if KO
*/
function containing($id,$type,$mode='object')
{
$cats = array();
$typeid=-1; $table='';
if ($type == '0' || $type == 'product') {
$typeid=self::TYPE_PRODUCT; $table='product'; $type='product';
} else if ($type == '1' || $type == 'supplier') {
$typeid=self::TYPE_SUPPLIER; $table='soc'; $type='fournisseur';
} else if ($type == '2' || $type == 'customer') {
$typeid=self::TYPE_CUSTOMER; $table='soc'; $type='societe';
} else if ($type == '3' || $type == 'member') {
$typeid=self::TYPE_MEMBER; $table='member'; $type='member';
} else if ($type == '4' || $type == 'contact') {
$typeid=self::TYPE_CONTACT; $table='socpeople'; $type='contact';
// For backward compatibility
if (is_numeric($type))
{
dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
// We want to reverse lookup
$map_type = array_flip($this->MAP_ID);
$type = $map_type[$type];
}
$sql = "SELECT ct.fk_categorie, c.label";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct, ".MAIN_DB_PREFIX."categorie as c";
$sql.= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".$table." = ".$id." AND c.type = ".$typeid;
$sql.= " AND c.entity IN (".getEntity('category',1).")";
$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as ct, " . MAIN_DB_PREFIX . "categorie as c";
$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . $id . " AND c.type = " . $this->MAP_ID[$type];
$sql .= " AND c.entity IN (" . getEntity( 'category', 1 ) . ")";
dol_syslog(get_class($this).'::containing', LOG_DEBUG);
$res = $this->db->query($sql);
if ($res)
{
@ -1241,19 +1283,26 @@ class Categorie extends CommonObject
*/
function rechercher($id, $nom, $type, $exact = false, $case = false)
{
// Deprecation warning
if (is_numeric($type)) {
dol_syslog(__METHOD__ . ': using numeric types is deprecated.', LOG_WARNING);
}
$cats = array();
$typeid=-1;
if ($type == 0 || $type == 'product') { $typeid=self::TYPE_PRODUCT; }
else if ($type == 1 || $type == 'supplier') { $typeid=self::TYPE_SUPPLIER; }
else if ($type == 2 || $type == 'customer') { $typeid=self::TYPE_CUSTOMER; }
else if ($type == 3 || $type == 'member') { $typeid=self::TYPE_MEMBER; }
else if ($type == 4 || $type == 'contact') { $typeid=self::TYPE_CONTACT; }
// For backward compatibility
if (is_numeric( $type )) {
// We want to reverse lookup
$map_type = array_flip( $this->MAP_ID );
$type = $map_type;
dol_syslog( get_class( $this ) . "::rechercher(): numeric types are deprecated, please use string instead",
LOG_WARNING );
}
// Generation requete recherche
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE type = ".$typeid;
$sql.= " AND entity IN (".getEntity('category',1).")";
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie";
$sql .= " WHERE type = " . $this->MAP_ID[$type];
$sql .= " AND entity IN (" . getEntity( 'category', 1 ) . ")";
if ($nom)
{
if (! $exact)

View File

@ -56,6 +56,9 @@ $object = new Categorie($db);
$extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
/*
* Actions
*/

View File

@ -64,6 +64,9 @@ $type=$object->type;
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
/*
* Actions
*/

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
@ -96,7 +96,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
{
$idtoremove=GETPOST('removedassigned');
if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=dol_json_decode($_SESSION['assignedtouser'],1);
if (! empty($_SESSION['assignedtouser'])) $tmpassigneduserids=json_decode($_SESSION['assignedtouser'],1);
else $tmpassigneduserids=array();
foreach ($tmpassigneduserids as $key => $val)
@ -104,7 +104,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')
if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]);
}
//var_dump($_POST['removedassigned']);exit;
$_SESSION['assignedtouser']=dol_json_encode($tmpassigneduserids);
$_SESSION['assignedtouser']=json_encode($tmpassigneduserids);
$donotclearsession=1;
if ($action == 'add') $action = 'create';
if ($action == 'update') $action = 'edit';
@ -119,10 +119,10 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
$assignedtouser=array();
if (! empty($_SESSION['assignedtouser']))
{
$assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
$assignedtouser=json_decode($_SESSION['assignedtouser'], true);
}
$assignedtouser[GETPOST('assignedtouser')]=array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'),'mandatory'=>1);
$_SESSION['assignedtouser']=dol_json_encode($assignedtouser);
$_SESSION['assignedtouser']=json_encode($assignedtouser);
}
$donotclearsession=1;
if ($action == 'add') $action = 'create';
@ -151,7 +151,7 @@ if ($action == 'add')
exit;
}
$percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):GETPOST("percentage"); // If status is -1 or 100, percentage is not defined and we must use status
$percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):(in_array(GETPOST('complete'),array(-1,100))?GETPOST('complete'):GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status
// Clean parameters
$datep=dol_mktime($fulldayevent?'00':GETPOST("aphour"), $fulldayevent?'00':GETPOST("apmin"), 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear"));
@ -215,7 +215,7 @@ if ($action == 'add')
$object->duree=((float) (GETPOST('dureehour') * 60) + (float) GETPOST('dureemin')) * 60;
$listofuserid=array();
if (! empty($_SESSION['assignedtouser'])) $listofuserid=dol_json_decode($_SESSION['assignedtouser']);
if (! empty($_SESSION['assignedtouser'])) $listofuserid=json_decode($_SESSION['assignedtouser'], true);
$i=0;
foreach($listofuserid as $key => $value)
{
@ -387,7 +387,7 @@ if ($action == 'update')
if (! empty($_SESSION['assignedtouser'])) // Now concat assigned users
{
// Restore array with key with same value than param 'id'
$tmplist1=dol_json_decode($_SESSION['assignedtouser'], true); $tmplist2=array();
$tmplist1=json_decode($_SESSION['assignedtouser'], true); $tmplist2=array();
foreach($tmplist1 as $key => $val)
{
if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']]=$val;
@ -671,19 +671,19 @@ if ($action == 'create')
}
// Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
print '<tr><td class="tdtop nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
$listofuserid=array();
if (empty($donotclearsession))
{
$assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
if ($assignedtouser) $listofuserid[$assignedtouser]=array('id'=>$assignedtouser,'mandatory'=>0,'transparency'=>$object->transparency); // Owner first
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
{
if (!empty($_SESSION['assignedtouser']))
{
$listofuserid=dol_json_decode($_SESSION['assignedtouser'], true);
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
@ -727,7 +727,7 @@ if ($action == 'create')
print '</td></tr>';
print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
$form->select_contacts(GETPOST('socid','int'),GETPOST('contactid'),'contactid',1);
$form->select_contacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
print '</td></tr>';
@ -739,7 +739,7 @@ if ($action == 'create')
// Projet associe
$langs->load("projects");
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
print '<tr><td>'.$langs->trans("Project").'</td><td>';
$numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:0),GETPOST("projectid")?GETPOST("projectid"):'','projectid');
if ($numproject==0)
@ -768,7 +768,7 @@ if ($action == 'create')
print '</td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('note',(GETPOST('note')?GETPOST('note'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_6,90);
$doleditor->Create();
@ -915,7 +915,7 @@ if ($id > 0)
}
// Assigned to
print '<tr><td class="nowrap">'.$langs->trans("ActionAssignedTo").'</td><td colspan="3">';
print '<tr><td class="tdtop nowrap">'.$langs->trans("ActionAssignedTo").'</td><td colspan="3">';
$listofuserid=array();
if (empty($donotclearsession))
{
@ -929,13 +929,13 @@ if ($id > 0)
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
}
}
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
{
if (!empty($_SESSION['assignedtouser']))
{
$listofuserid=dol_json_decode($_SESSION['assignedtouser'], true);
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
@ -968,7 +968,7 @@ if ($id > 0)
// Contact
print '<td>'.$langs->trans("Contact").'</td><td width="30%">';
$form->select_contacts($object->socid, $object->contactid,'contactid',1);
$form->select_contacts($object->socid, $object->contactid, 'contactid', 1, '', '', 0, 'minwidth200');
print '</td></tr>';
}
@ -981,7 +981,7 @@ if ($id > 0)
// Projet associe
$langs->load("project");
print '<tr><td width="30%" valign="top">'.$langs->trans("Project").'</td><td colspan="3">';
print '<tr><td width="30%">'.$langs->trans("Project").'</td><td colspan="3">';
$numprojet=$formproject->select_projects($object->socid,$object->fk_project,'projectid');
if ($numprojet==0)
{
@ -1004,7 +1004,7 @@ if ($id > 0)
}
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('note',$object->note,'',240,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,90);
@ -1101,13 +1101,13 @@ if ($id > 0)
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
}
}
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
{
if (!empty($_SESSION['assignedtouser']))
{
$listofuserid=dol_json_decode($_SESSION['assignedtouser'], true);
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
print $form->select_dolusers_forevent('view','assignedtouser',1);
@ -1168,7 +1168,7 @@ if ($id > 0)
// Project
if (! empty($conf->projet->enabled))
{
print '<tr><td width="30%" valign="top">'.$langs->trans("Project").'</td><td colspan="3">';
print '<tr><td width="30%">'.$langs->trans("Project").'</td><td colspan="3">';
if ($object->fk_project)
{
$project=new Project($db);
@ -1192,7 +1192,7 @@ if ($id > 0)
}
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
print dol_htmlentitiesbr($object->note);
print '</td></tr>';
@ -1267,7 +1267,7 @@ if ($id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewcal" value="'.$langs->trans("ViewCal").'">';
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewcal" value="'.$langs->trans("ViewCal").'">';
print '</form>'."\n";
print '<form name="listactionsfilterweek" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1276,7 +1276,7 @@ if ($id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
print '</form>'."\n";
print '<form name="listactionsfilterday" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1285,7 +1285,7 @@ if ($id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewday" value="'.$langs->trans("ViewDay").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewday" value="'.$langs->trans("ViewDay").'">';
print '</form>'."\n";
print '<form name="listactionsfilterperuser" action="'.DOL_URL_ROOT.'/comm/action/peruser.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1294,7 +1294,7 @@ if ($id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewperuser" value="'.$langs->trans("ViewPerUser").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewperuser" value="'.$langs->trans("ViewPerUser").'">';
print '</form>'."\n";
print '</div>';

View File

@ -61,6 +61,7 @@ class ActionComm extends CommonObject
/**
* @var string
* @deprecated Use $label
* @see label
*/
public $libelle;
@ -71,6 +72,7 @@ class ActionComm extends CommonObject
* Object user that create action
* @var User
* @deprecated
* @see authorid
*/
var $author;
@ -78,6 +80,7 @@ class ActionComm extends CommonObject
* Object user that modified action
* @var User
* @deprecated
* @see usermodid
*/
var $usermod;
var $authorid; // Id user that create action
@ -114,6 +117,7 @@ class ActionComm extends CommonObject
* Object user of owner
* @var User
* @deprecated
* @see userownerid
*/
var $usertodo;
@ -121,6 +125,7 @@ class ActionComm extends CommonObject
* Object user that did action
* @var User
* @deprecated
* @see userdoneid
*/
var $userdone;
@ -130,12 +135,16 @@ class ActionComm extends CommonObject
/**
* Company linked to action (optional)
* @var Societe|null
* @deprecated
* @see socid
*/
var $societe;
/**
* Contact linked to action (optional)
* @var Contact|null
* @deprecated
* @see contactid
*/
var $contact;
@ -468,7 +477,7 @@ class ActionComm extends CommonObject
$this->fulldayevent = $obj->fulldayevent;
$this->location = $obj->location;
$this->transparency = $obj->transparency;
$this->punctual = $obj->punctual;
$this->punctual = $obj->punctual; // deprecated
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
$this->contactid = $obj->fk_contact; // To have fetch_contact method working

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
@ -143,7 +143,7 @@ if ($object->id > 0)
print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$object->label.'</td></tr>';
// Full day event
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent).'</td></tr>';
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>';
// Date start
print '<tr><td width="30%">'.$langs->trans("DateActionStart").'</td><td colspan="3">';
@ -186,13 +186,13 @@ if ($object->id > 0)
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
}
}
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
{
if (!empty($_SESSION['assignedtouser']))
{
$listofuserid=dol_json_decode($_SESSION['assignedtouser'], true);
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
print $form->select_dolusers_forevent('view','assignedtouser',1);
@ -235,7 +235,7 @@ if ($object->id > 0)
// Project
if (! empty($conf->projet->enabled))
{
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$langs->trans("Project").'</td><td colspan="3">';
if ($object->fk_project)
{
$project=new Project($db);
@ -274,7 +274,7 @@ if ($object->id > 0)
}
print '<tr><td width="30%" nowrap>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td width="30%" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
@ -294,7 +294,7 @@ if ($object->id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewcal" value="'.$langs->trans("ViewCal").'">';
print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewcal" value="'.$langs->trans("ViewCal").'">';
print '</form>'."\n";
print '<form name="listactionsfilterweek" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -303,7 +303,7 @@ if ($object->id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewweek" value="'.$langs->trans("ViewWeek").'">';
print '</form>'."\n";
print '<form name="listactionsfilterday" action="'.DOL_URL_ROOT.'/comm/action/index.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -312,7 +312,7 @@ if ($object->id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewday" value="'.$langs->trans("ViewDay").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewday" value="'.$langs->trans("ViewDay").'">';
print '</form>'."\n";
print '<form name="listactionsfilterperuser" action="'.DOL_URL_ROOT.'/comm/action/peruser.php" method="POST" style="float: left; padding-right: 10px;">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -321,7 +321,7 @@ if ($object->id > 0)
print '<input type="hidden" name="month" value="'.dol_print_date($object->datep,'%m').'">';
print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
//print '<input type="hidden" name="day" value="'.dol_print_date($object->datep,'%d').'">';
print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone"').' <input type="submit" style="min-width: 120px" class="button" name="viewperuser" value="'.$langs->trans("ViewPerUser").'">';
print img_picto($langs->trans("ViewCal"),'object_calendarperuser','class="hideonsmartphone pictoactionview"').' <input type="submit" style="min-width: 120px" class="button buttonactionview" name="viewperuser" value="'.$langs->trans("ViewPerUser").'">';
print '</form>'."\n";
print '</div>';

View File

@ -1709,10 +1709,12 @@ if ($action == 'create')
$somethingshown = $formfile->show_documents('askpricesupplier', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
/*
* Linked object block
*/
$somethingshown = $object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
@ -1736,8 +1738,8 @@ if ($action == 'create')
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
$fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
@ -1762,8 +1764,8 @@ if ($action == 'create')
dol_print_error($db, $result);
exit();
}
$fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
$fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<br>';

View File

@ -59,14 +59,42 @@ class AskPriceSupplier extends CommonObject
var $client; // Objet societe client (a charger par fetch_client)
var $fk_project;
/**
* @deprecated
* @see user_author_id
*/
var $author;
var $ref;
var $ref_fourn; //Reference saisie lors de l'ajout d'une ligne à la demande
var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed)
var $datec; // Date of creation
var $date; // Date of proposal
var $date_livraison;
/**
* @deprecated
* @see date_creation
*/
var $datec;
/**
* Creation date
* @var int
*/
public $date_creation;
/**
* @deprecated
* @see date_validation
*/
var $datev;
/**
* Validation date
* @var int
*/
public $date_validation;
var $user_author_id;
var $user_valid_id;
var $user_close_id;
@ -76,9 +104,22 @@ class AskPriceSupplier extends CommonObject
var $total_localtax1; // Total Local Taxes 1
var $total_localtax2; // Total Local Taxes 2
var $total_ttc; // Total with tax
var $price; // deprecated (for compatibility)
var $tva; // deprecated (for compatibility)
var $total; // deprecated (for compatibility)
/**
* @deprecated
* @see price_ht
*/
var $price;
/**
* @deprecated
* @see total_tva
*/
var $tva;
/**
* @deprecated
* @see total_ttc
*/
var $total;
var $cond_reglement_id;
var $cond_reglement_code;
@ -88,7 +129,11 @@ class AskPriceSupplier extends CommonObject
var $remise;
var $remise_percent;
var $remise_absolue;
var $note; // deprecated (for compatibility)
/**
* @deprecated
* @see note_public, note_private
*/
var $note;
var $note_private;
var $note_public;
var $shipping_method_id;
@ -1031,7 +1076,7 @@ class AskPriceSupplier extends CommonObject
$this->remise = $obj->remise;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
$this->total = $obj->total; // TODO obsolete
$this->total = $obj->total; // TODO deprecated
$this->total_ht = $obj->total_ht;
$this->total_tva = $obj->tva;
$this->total_localtax1 = $obj->localtax1;
@ -1040,14 +1085,14 @@ class AskPriceSupplier extends CommonObject
$this->socid = $obj->fk_soc;
$this->fk_project = $obj->fk_projet;
$this->modelpdf = $obj->model_pdf;
$this->note = $obj->note_private; // TODO obsolete
$this->note = $obj->note_private; // TODO deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->statut = $obj->fk_statut;
$this->statut_libelle = $obj->statut_label;
$this->datec = $this->db->jdate($obj->datec); // TODO obsolete
$this->datev = $this->db->jdate($obj->datev); // TODO obsolete
$this->datec = $this->db->jdate($obj->datec); // TODO deprecated
$this->datev = $this->db->jdate($obj->datev); // TODO deprecated
$this->date_creation = $this->db->jdate($obj->datec); //Creation date
$this->date_validation = $this->db->jdate($obj->datev); //Validation date
$this->date_livraison = $this->db->jdate($obj->date_livraison);
@ -2431,7 +2476,17 @@ class AskPriceSupplierLine extends CommonObject
var $fk_parent_line;
var $desc; // Description ligne
var $fk_product; // Id produit predefini
var $product_type = 0; // Type 0 = product, 1 = Service
/**
* @deprecated
* @see product_type
*/
var $fk_product_type;
/**
* Product type
* @var int
* @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE
*/
public $product_type = Product::TYPE_PRODUCT;
var $qty;
var $tva_tx;
@ -2459,14 +2514,43 @@ class AskPriceSupplierLine extends CommonObject
var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne
var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne
// Ne plus utiliser
/**
* @deprecated
* @see remise_percent, fk_remise_except
*/
var $remise;
/**
* @deprecated
* @see subprice
*/
var $price;
// From llx_product
var $ref; // Reference produit
var $libelle; // Label produit
var $product_desc; // Description produit
/**
* @deprecated
* @see product_ref
*/
var $ref;
/**
* Product reference
* @var string
*/
public $product_ref;
/**
* @deprecated
* @see product_label
*/
var $libelle;
/**
* Product label
* @var string
*/
public $product_label;
/**
* Product description
* @var string
*/
public $product_desc;
var $localtax1_tx; // Local tax 1
var $localtax2_tx; // Local tax 2

View File

@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
@ -140,7 +141,7 @@ if (empty($reshook))
if ($result < 0) setEventMessage($object->error,$object->errors,'errors');
}
// update prospect level
// set communication status
if ($action == 'setstcomm')
{
$object->fetch($id);
@ -468,6 +469,14 @@ if ($id > 0)
print '</div></td></tr>';
}
// Categories
if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) {
print '<tr><td>' . $langs->trans( "Categories" ) . '</td>';
print '<td colspan="3">';
print $form->showCategories( $object->id, 'customer', 1 );
print "</td></tr>";
}
// Other attributes
$parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook

View File

@ -421,7 +421,7 @@ class Mailing extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
return 1;
return $this->delete_targets();
}
else
{
@ -429,6 +429,29 @@ class Mailing extends CommonObject
return -1;
}
}
/**
* Delete targets emailing
*
* @return int 1 if OK, 0 if error
*/
function delete_targets()
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql.= " WHERE fk_mailing = ".$this->id;
dol_syslog("Mailing::delete_targets", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
return 1;
}
else
{
$this->error=$this->db->lasterror();
return 0;
}
}
/**

View File

@ -41,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/modules/propale/modules_propale.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/propal.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
@ -305,7 +306,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->statut = Propal::STATUS_DRAFT;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -331,7 +333,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -640,7 +643,6 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Go back to draft
if ($action == 'modif' && $user->rights->propal->creer)
{
@ -1257,6 +1259,7 @@ $formother = new FormOther($db);
$formfile = new FormFile($db);
$formpropal = new FormPropal($db);
$companystatic = new Societe($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
$now = dol_now();
@ -1341,7 +1344,7 @@ if ($action == 'create')
print '<table class="border" width="100%">';
// Reference
print '<tr><td class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
print '<tr><td width="25%" class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
// Ref customer
print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td colspan="2">';
@ -1445,13 +1448,20 @@ if ($action == 'create')
}
print '</td></tr>';
// Model
print '<tr>';
print '<td>' . $langs->trans("DefaultModel") . '</td>';
print '<td colspan="2">';
$liste = ModelePDFPropales::liste_modeles($db);
print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF));
print "</td></tr>";
// Project
if (! empty($conf->projet->enabled) && $socid > 0)
{
$projectid = GETPOST('projectid')?GETPOST('projectid'):0;
if ($origin == 'project') $projectid = ($originid ? $originid : 0);
$langs->load("projects");
print '<tr>';
print '<td>' . $langs->trans("Project") . '</td><td colspan="2">';
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
print ' &nbsp; <a href="../projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
print '</td>';
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
@ -1463,25 +1473,41 @@ if ($action == 'create')
print '</td></tr>';
}
// Project
if (! empty($conf->projet->enabled) && $socid > 0)
// Template to use by default
print '<tr>';
print '<td>' . $langs->trans("DefaultModel") . '</td>';
print '<td colspan="2">';
$liste = ModelePDFPropales::liste_modeles($db);
print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF));
print "</td></tr>";
// Public note
print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
print '<td valign="top" colspan="2">';
$note_public = '';
if (is_object($objectsrc)) // Take value from source object
{
$formproject = new FormProjets($db);
$projectid = 0;
if ($origin == 'project')
$projectid = ($originid ? $originid : 0);
$note_public = $objectsrc->note_public;
}
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
if (empty($user->societe_id))
{
print '<tr>';
print '<td>' . $langs->trans("Project") . '</td><td colspan="2">';
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
if ($numprojet == 0) {
$langs->load("projects");
print ' &nbsp; <a href="../projet/card.php?socid=' . $soc->id . '&action=create">' . $langs->trans("AddProject") . '</a>';
print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>';
print '<td valign="top" colspan="2">';
$note_private = '';
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) // Take value from source object
{
$note_private = $objectsrc->note_private;
}
print '</td>';
print '</tr>';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
print '</td></tr>';
}
// Other attributes
@ -2281,10 +2307,13 @@ if ($action == 'create')
$somethingshown = $formfile->show_documents('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
/*
* Linked object block
*/
$somethingshown = $object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object);
if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// print '</td><td valign="top" width="50%">';
@ -2311,8 +2340,8 @@ if ($action == 'create')
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
@ -2336,8 +2365,8 @@ if ($action == 'create')
dol_print_error($db, $result);
exit();
}
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<br>';

View File

@ -75,26 +75,35 @@ class Propal extends CommonObject
/**
* Status of the quote
* Check the following constants:
* - STATUS_DRAFT
* - STATUS_VALIDATED
* - STATUS_SIGNED
* - STATUS_NOTSIGNED
* - STATUS_BILLED
* @var int
* @see Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED
*/
var $statut;
/**
* Date of creation
* @var
* @deprecated
* @see date_creation
*/
var $datec;
/**
* Date of validation
* @var
* Creation date
* @var int
*/
public $date_creation;
/**
* @deprecated
* @see date_validation
*/
var $datev;
/**
* Validation date
* @var int
*/
public $date_validation;
/**
* Date of the quote
* @var
@ -102,8 +111,8 @@ class Propal extends CommonObject
var $date;
/**
* Same than date ¿?
* @var
* @deprecated
* @see date
*/
var $datep;
var $date_livraison;
@ -121,14 +130,17 @@ class Propal extends CommonObject
/**
* @deprecated
* @see total_ht
*/
var $price;
/**
* @deprecated
* @see total_tva
*/
var $tva;
/**
* @deprecated
* @see total_ttc
*/
var $total;
@ -142,6 +154,7 @@ class Propal extends CommonObject
var $remise_absolue;
/**
* @deprecated
* @see note_private, note_public
*/
var $note;
var $note_private;
@ -1048,8 +1061,10 @@ class Propal extends CommonObject
*/
function createFromClone($socid=0)
{
global $user,$langs,$conf,$hookmanager;
global $db, $user,$langs,$conf,$hookmanager;
dol_include_once('/projet/class.project.class.php');
$this->context['createfromclone']='createfromclone';
$error=0;
@ -1074,7 +1089,16 @@ class Propal extends CommonObject
$this->socid = $objsoc->id;
$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$this->fk_project = '';
$project = new Project($db);
if($objFrom->fk_project > 0 && $project->fetch($objFrom->fk_project)) {
if($project->socid <= 0) $this->fk_project = $objFrom->fk_project;
else $this->fk_project = '';
} else {
$this->fk_project = '';
}
$this->fk_delivery_address = '';
}
@ -1222,7 +1246,7 @@ class Propal extends CommonObject
$this->remise = $obj->remise;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
$this->total = $obj->total; // TODO obsolete
$this->total = $obj->total; // TODO deprecated
$this->total_ht = $obj->total_ht;
$this->total_tva = $obj->tva;
$this->total_localtax1 = $obj->localtax1;
@ -1231,14 +1255,14 @@ class Propal extends CommonObject
$this->socid = $obj->fk_soc;
$this->fk_project = $obj->fk_projet;
$this->modelpdf = $obj->model_pdf;
$this->note = $obj->note_private; // TODO obsolete
$this->note = $obj->note_private; // TODO deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->statut = $obj->fk_statut;
$this->statut_libelle = $obj->statut_label;
$this->datec = $this->db->jdate($obj->datec); // TODO obsolete
$this->datev = $this->db->jdate($obj->datev); // TODO obsolete
$this->datec = $this->db->jdate($obj->datec); // TODO deprecated
$this->datev = $this->db->jdate($obj->datev); // TODO deprecated
$this->date_creation = $this->db->jdate($obj->datec); //Creation date
$this->date_validation = $this->db->jdate($obj->datev); //Validation date
$this->date = $this->db->jdate($obj->dp); // Proposal date
@ -1967,9 +1991,12 @@ class Propal extends CommonObject
*
* @return int <0 si ko, >0 si ok
* @deprecated
* @see classifyBilled()
*/
function classer_facturee()
{
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
return $this->classifyBilled();
}
@ -2724,7 +2751,7 @@ class Propal extends CommonObject
* Return clicable link of object (with eventually picto)
*
* @param int $withpicto Add picto into link
* @param string $option Where point the link ('compta', 'expedition', 'document', ...)
* @param string $option Where point the link ('expedition', 'document', ...)
* @param string $get_params Parametres added to url
* @return string String with URL
*/
@ -2912,17 +2939,19 @@ class PropaleLigne extends CommonObjectLine
var $oldline;
// From llx_propaldet
var $rowid;
var $fk_propal;
var $fk_parent_line;
var $desc; // Description ligne
var $fk_product; // Id produit predefini
/**
* @deprecated
* @see product_type
*/
var $fk_product_type;
/**
* Product type.
* Use the following constants:
* - Product::TYPE_PRODUCT
* - Product::TYPE_SERVICE
* @var int
* @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE
*/
var $product_type = Product::TYPE_PRODUCT;
@ -2952,14 +2981,43 @@ class PropaleLigne extends CommonObjectLine
var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne
var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne
// Ne plus utiliser
/**
* @deprecated
* @see $remise_percent, $fk_remise_except
*/
var $remise;
/**
* @deprecated
* @see subprice
*/
var $price;
// From llx_product
var $ref; // Reference produit
var $libelle; // Label produit
var $product_desc; // Description produit
/**
* @deprecated
* @see product_ref
*/
var $ref;
/**
* Product reference
* @var string
*/
public $product_ref;
/**
* @deprecated
* @see product_label
*/
var $libelle;
/**
* Product label
* @var string
*/
public $product_label;
/**
* Product description
* @var string
*/
public $product_desc;
var $localtax1_tx; // Local tax 1
var $localtax2_tx; // Local tax 2
@ -3007,7 +3065,8 @@ class PropaleLigne extends CommonObjectLine
{
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
$this->id = $objp->rowid;
$this->rowid = $objp->rowid; // deprecated
$this->fk_propal = $objp->fk_propal;
$this->fk_parent_line = $objp->fk_parent_line;
$this->label = $objp->custom_label;
@ -3016,7 +3075,7 @@ class PropaleLigne extends CommonObjectLine
$this->price = $objp->price; // deprecated
$this->subprice = $objp->subprice;
$this->tva_tx = $objp->tva_tx;
$this->remise = $objp->remise;
$this->remise = $objp->remise; // deprecated
$this->remise_percent = $objp->remise_percent;
$this->fk_remise_except = $objp->fk_remise_except;
$this->fk_product = $objp->fk_product;

View File

@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$langs->load('compta');
$langs->load('other');
$langs->load('companies');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');

View File

@ -56,6 +56,7 @@ $search_refcustomer=GETPOST('search_refcustomer','alpha');
$search_societe=GETPOST('search_societe','alpha');
$search_montant_ht=GETPOST('search_montant_ht','alpha');
$search_author=GETPOST('search_author','alpha');
$search_product_category=GETPOST('search_product_category','int');
$search_town=GETPOST('search_town','alpha');
$viewstatut=$db->escape(GETPOST('viewstatut'));
$object_statut=$db->escape(GETPOST('propal_statut'));
@ -91,6 +92,7 @@ if (GETPOST("button_removefilter") || GETPOST("button_removefilter_x")) // Both
$search_societe='';
$search_montant_ht='';
$search_author='';
$search_product_category='';
$search_town='';
$year='';
$month='';
@ -145,14 +147,15 @@ if (! $sortorder) $sortorder='DESC';
$limit = $conf->liste_limit;
if (! $sall) $sql = 'SELECT';
else $sql = 'SELECT DISTINCT';
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql.= ' s.rowid, s.nom as name, s.town, s.client, s.code_client,';
$sql.= ' p.rowid as propalid, p.note_private, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,';
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,";
$sql.= ' u.login';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p';
if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid';
// We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -190,7 +193,8 @@ if ($search_montant_ht != '')
if ($sall) {
$sql .= natural_search(array('s.nom', 'p.note_private', 'p.note_public', 'pd.description'), $sall);
}
if ($socid) $sql.= ' AND s.rowid = '.$socid;
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
if ($viewstatut <> '')
{
$sql.= ' AND p.fk_statut IN ('.$viewstatut.')';
@ -223,7 +227,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
//print $sql;
$sql.= $db->plimit($limit + 1,$offset);
$result=$db->query($sql);
@ -265,15 +269,28 @@ if ($result)
if ($user->rights->societe->client->voir || $socid)
{
$langs->load("commercial");
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
$moreforfilter.='</div>';
}
// If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid)
{
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
$moreforfilter.=$form->select_dolusers($search_user,'search_user',1);
$moreforfilter.='</div>';
}
// If the user can view prospects other than his'
if ($conf->categorie->enabled && $user->rights->produit->lire)
{
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
$moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1);
$moreforfilter.='</div>';
}
if (! empty($moreforfilter))
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
$langs->load('propal');
$langs->load('compta');
$langs->load('bills');
$langs->load("companies");
$id = GETPOST('id','int');
$ref=GETPOST('ref','alpha');
@ -103,7 +104,7 @@ if ($id > 0 || ! empty($ref))
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
// Ligne info remises tiers
// Discounts
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
if ($societe->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount");

View File

@ -204,6 +204,9 @@ if (empty($reshook))
$formother=new FormOther($db);
$form=new Form($db);
$prospectstatic=new Client($db);
$prospectstatic->client=2;
$prospectstatic->loadCacheOfProspStatus();
$sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.datec, s.status as status, s.code_client, s.client,";
$sql.= " s.prefix_comm, s.fk_prospectlevel, s.fk_stcomm as stcomm_id,";
@ -353,7 +356,7 @@ if ($resql)
print '<input class="flat" type="text" size="10" name="search_datec" value="'.$search_datec.'">';
print '</td>';
// Prospect levelt
// Prospect level
print '<td class="liste_titre" align="center">';
$options_from = '<option value="">&nbsp;</option>'; // Generate in $options_from the list of each option sorted
foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
@ -380,9 +383,12 @@ if ($resql)
// Prospect status
print '<td class="liste_titre" align="center">';
// TODO Add here a list of prospect status
//print $form->selectarray($htmlname, $array, $search_stcomm);
//print '&nbsp;';
$arraystcomm=array();
foreach($prospectstatic->cacheprospectstatus as $key => $val)
{
$arraystcomm[$val['id']]=$val['label'];
}
print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, 1);
print '</td>';
print '<td class="liste_titre" align="center">';
@ -390,7 +396,7 @@ if ($resql)
print '</td>';
print '<td class="liste_titre" align="center">';
print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status);
print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status);
print '</td>';
// Print the search button
@ -407,10 +413,6 @@ if ($resql)
$i = 0;
$var=true;
$prospectstatic=new Client($db);
$prospectstatic->client=2;
$prospectstatic->loadCacheOfProspStatus();
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);

View File

@ -129,7 +129,7 @@ if ($id > 0 || ! empty($ref))
print '</tr>';
// Si fichier detail PDF existe
// TODO obsolete ?
// TODO deprecated ?
if (file_exists($filedetail))
{
print "<tr ".$bc[$var]."><td>Commande detaillee</td>";

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
@ -1214,6 +1214,7 @@ llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|
$form = new Form($db);
$formfile = new FormFile($db);
$formorder = new FormOrder($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
/**
* *******************************************************************
@ -1320,7 +1321,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<table class="border" width="100%">';
// Reference
print '<tr><td class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
print '<tr><td width="25%" class="fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
// Reference client
print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td colspan="2">';
@ -1422,14 +1423,16 @@ if ($action == 'create' && $user->rights->commande->creer)
// Project
if (! empty($conf->projet->enabled) && $socid > 0)
{
$formproject = new FormProjets($db);
$projectid = GETPOST('projectid')?GETPOST('projectid'):0;
if ($origin == 'project') $projectid = ($originid ? $originid : 0);
print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
$langs->load("projects");
print '<tr>';
print '<td>' . $langs->trans("Project") . '</td><td colspan="2">';
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
if ($numprojet == 0) {
print ' &nbsp; <a href="' . DOL_URL_ROOT . '/projet/card.php?socid=' . $soc->id . '&action=create">' . $langs->trans("AddProject") . '</a>';
}
print '</td></tr>';
print ' &nbsp; <a href="../projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
print '</td>';
print '</tr>';
}
// Incoterms
@ -1458,29 +1461,30 @@ if ($action == 'create' && $user->rights->commande->creer)
print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF);
print "</td></tr>";
// Note publique
// Note public
print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
print '</td></tr>';
// Note privee
// Note private
if (empty($user->societe_id)) {
print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>';
print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
print '</td></tr>';
}
if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
{
// TODO for compatibility
if ($origin == 'contrat') {
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
@ -1514,8 +1518,11 @@ if ($action == 'create' && $user->rights->commande->creer)
}
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>";
} else {
if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) {
}
else
{
if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE))
{
/*
* Services/produits predefinis
*/
@ -2298,10 +2305,13 @@ if ($action == 'create' && $user->rights->commande->creer)
$delallowed = $user->rights->commande->supprimer;
$somethingshown = $formfile->show_documents('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
/*
* Linked object block
*/
$somethingshown = $object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object);
//if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// print '</td><td valign="top" width="50%">';
@ -2324,8 +2334,7 @@ if ($action == 'create' && $user->rights->commande->creer)
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
@ -2349,8 +2358,8 @@ if ($action == 'create' && $user->rights->commande->creer)
dol_print_error($db, $result);
exit();
}
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<br>';

View File

@ -74,17 +74,15 @@ class Commande extends CommonOrder
/**
* Status of the order. Check the following constants:
* - STATUS_CANCELED
* - STATUS_DRAFT
* - STATUS_ACCEPTED
* - STATUS_CLOSED
* @var int
* @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED
*/
var $statut;
/**
* @deprecated
* @see billed
*/
var $facturee; // deprecated
var $facturee;
var $billed; // billed or not
var $brouillon;
@ -100,7 +98,11 @@ class Commande extends CommonOrder
var $fk_delivery_address;
var $address;
var $date; // Date commande
var $date_commande; // Date commande (deprecated)
/**
* @deprecated
* @see date
*/
var $date_commande;
var $date_livraison; // Date livraison souhaitee
var $shipping_method_id;
var $fk_remise_except;
@ -116,7 +118,11 @@ class Commande extends CommonOrder
var $rang;
var $special_code;
var $source; // Origin of order
var $note; // deprecated
/**
* @deprecated
* @see note_private, note_public
*/
var $note;
var $note_private;
var $note_public;
var $extraparams=array();
@ -1033,7 +1039,9 @@ class Commande extends CommonOrder
*/
function createFromProposal($object)
{
global $conf,$user,$langs,$hookmanager;
global $db, $conf,$user,$langs,$hookmanager;
dol_include_once('/core/class/extrafields.class.php');
$error=0;
@ -1104,9 +1112,15 @@ class Commande extends CommonOrder
// get extrafields from original line
$object->fetch_optionals($object->id);
foreach($object->array_options as $options_key => $value)
$this->array_options[$options_key] = $value;
$e = new ExtraFields($db);
$element_extrafields = $e->fetch_name_optionals_label($this->element);
foreach($object->array_options as $options_key => $value) {
if(array_key_exists(str_replace('options_', '', $options_key), $element_extrafields)){
$this->array_options[$options_key] = $value;
}
}
// Possibility to add external linked objects with hooks
$this->linked_objects[$this->origin] = $this->origin_id;
if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
@ -1728,6 +1742,7 @@ class Commande extends CommonOrder
$i++;
}
$this->db->free($result);
return 1;
@ -1776,7 +1791,7 @@ class Commande extends CommonOrder
* @param int $filtre_statut Filter on status
* @return int <0 if KO, Nb of lines found if OK
*
* TODO deprecated, move to Shipping class
* TODO deprecate, move to Shipping class
*/
function loadExpeditions($filtre_statut=-1)
{
@ -1823,7 +1838,7 @@ class Commande extends CommonOrder
*
* @return int Nb of shipments
*
* TODO deprecated, move to Shipping class
* TODO deprecate, move to Shipping class
*/
function nb_expedition()
{
@ -1849,7 +1864,7 @@ class Commande extends CommonOrder
* @param int $filtre_statut Filtre sur statut
* @return int 0 si OK, <0 si KO
*
* TODO deprecated, move to Shipping class
* TODO deprecate, move to Shipping class
*/
function livraison_array($filtre_statut=self::STATUS_CANCELED)
{
@ -2399,9 +2414,12 @@ class Commande extends CommonOrder
*
* @return int <0 if ko, >0 if ok
* @deprecated
* @see classifyBilled()
*/
function classer_facturee()
{
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
return $this->classifyBilled();
}
@ -3346,6 +3364,7 @@ class OrderLine extends CommonOrderLine
* Id of parent order
* @var int
* @deprecated Use fk_commande
* @see fk_commande
*/
public $commande_id;
@ -3367,6 +3386,7 @@ class OrderLine extends CommonOrderLine
/**
* @deprecated
* @see remise_percent, fk_remise_except
*/
var $remise;

View File

@ -41,6 +41,7 @@ class Account extends CommonObject
/**
* @var int Use id instead of rowid
* @deprecated
* @see id
*/
var $rowid;
var $id;
@ -240,6 +241,11 @@ class Account extends CommonObject
*/
function addline($date, $oper, $label, $amount, $num_chq, $categorie, $user, $emetteur='',$banque='')
{
// Deprecatîon warning
if (is_numeric($oper)) {
dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING);
}
// Clean parameters
$emetteur=trim($emetteur);
$banque=trim($banque);

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
@ -177,7 +177,7 @@ $form->select_comptes($account_to,'account_to',0,'',1);
print "</td>\n";
print "<td>";
$form->select_date($dateo,'','','','','add');
$form->select_date((! empty($dateo)?$dateo:''),'','','','','add');
print "</td>\n";
print '<td><input name="label" class="flat" type="text" size="40" value="'.$label.'"></td>';
print '<td><input name="amount" class="flat" type="text" size="8" value="'.$amount.'"></td>';

View File

@ -44,7 +44,11 @@ class Deplacement extends CommonObject
var $fk_user_author;
var $fk_user;
var $km;
var $note; // TODO obsolete
/**
* @deprecated
* @see note_private, note_public
*/
var $note; // TODO deprecated
var $note_private;
var $note_public;
var $socid;

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
@ -1759,10 +1759,8 @@ if (empty($reshook))
$upload_dir = $conf->facture->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret)
setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
$action = '';
}
}
@ -1856,6 +1854,8 @@ $form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
$bankaccountstatic = new Account($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
$now = dol_now();
llxHeader('', $langs->trans('Bill'), 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
@ -2082,22 +2082,21 @@ if ($action == 'create')
}
print '<tr><td valign="top" class="fieldrequired">' . $langs->trans('Type') . '</td><td colspan="2">';
print '<table class="nobordernopadding">' . "\n";
print '<div class="tagtable">' . "\n";
// Standard invoice
print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" id="radio_standard" name="type" value="0"' . (GETPOST('type') == 0 ? ' checked' : '') . '>';
print '</td><td valign="middle">';
$desc = $form->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1);
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" id="radio_standard" name="type" value="0"' . (GETPOST('type') == 0 ? ' checked' : '') . '> ';
$desc = $form->textwithpicto($tmp.$langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</td></tr>' . "\n";
print '</div></div>';
if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid))))
{
// Deposit
print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" id="radio_deposit" name="type" value="3"' . (GETPOST('type') == 3 ? ' checked' : '') . '>';
print '</td><td valign="middle" class="nowrap">';
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" id="radio_deposit" name="type" value="3"' . (GETPOST('type') == 3 ? ' checked' : '') . '> ';
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#typedeposit, #valuedeposit").click(function() {
@ -2105,9 +2104,13 @@ if ($action == 'create')
});
});
</script>';
$desc = $form->textwithpicto($langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1);
print '<table class="nobordernopadding"><tr><td>' . $desc . '</td>';
if (($origin == 'propal') || ($origin == 'commande')) {
$desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3);
print '<table class="nobordernopadding"><tr><td>';
print $desc;
print '</td>';
if (($origin == 'propal') || ($origin == 'commande'))
{
print '<td class="nowrap" style="padding-left: 5px">';
$arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1);
@ -2115,44 +2118,41 @@ if ($action == 'create')
print '<td class="nowrap" style="padding-left: 5px">' . $langs->trans('Value') . ':<input type="text" id="valuedeposit" name="valuedeposit" size="3" value="' . GETPOST('valuedeposit', 'int') . '"/>';
}
print '</td></tr></table>';
print '</td></tr>' . "\n";
print '</div></div>';
}
if ($socid > 0)
{
if (! empty($conf->global->INVOICE_USE_SITUATION))
{
// First situation invoice
print '<tr height="18"><td width="16px" valign="middle">';
print '<input type="radio" name="type" value="5"' . (GETPOST('type') == 5 ? ' checked' : '') . '>';
print '</td><td valign="middle">';
$desc = $form->textwithpicto($langs->trans("InvoiceFirstSituationAsk"), $langs->transnoentities("InvoiceFirstSituationDesc"), 1);
print $desc;
print '</td></tr>' . "\n";
// First situation invoice
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" value="5"' . (GETPOST('type') == 5 ? ' checked' : '') . '> ';
$desc = $form->textwithpicto($tmp.$langs->trans("InvoiceFirstSituationAsk"), $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</div></div>';
// Next situation invoice
$opt = $form->load_situation_invoices(GETPOST('originid'), $socid);
print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" value="5"' . (GETPOST('type') == 5 && GETPOST('originid') ? ' checked' : '') . ' ';
if ($opt == '<option value ="0" selected>' . $langs->trans('NoSituations') . '</option>' || (GETPOST('origin') && GETPOST('origin') != 'facture')) print 'disabled';
print '>';
print '</td><td valign="middle">';
$text = $langs->trans("InvoiceSituationAsk") . ' ';
$text .= '<select class="flat" id="situations" name="situations">';
$text .= $opt;
$text .= '</select>';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1);
print $desc;
print '</td></tr>' . "\n";
// Next situation invoice
$opt = $form->selectSituationInvoices(GETPOST('originid'), $socid);
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" value="5"' . (GETPOST('type') == 5 && GETPOST('originid') ? ' checked' : '');
if ($opt == ('<option value ="0" selected>' . $langs->trans('NoSituations') . '</option>') || (GETPOST('origin') && GETPOST('origin') != 'facture')) $tmp.=' disabled';
$tmp.= '> ';
$text = $tmp.$langs->trans("InvoiceSituationAsk") . ' ';
$text .= '<select class="flat" id="situations" name="situations">';
$text .= $opt;
$text .= '</select>';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceSituationDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</div></div>';
}
// Replacement
print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked' : '');
if (! $options)
print ' disabled';
print '>';
print '</td><td valign="middle">';
print '<!-- replacement line --><div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_replacement" value="1"' . (GETPOST('type') == 1 ? ' checked' : '');
if (! $options) $tmp.=' disabled';
$tmp.='> ';
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#fac_replacement").change(function() {
@ -2160,7 +2160,7 @@ if ($action == 'create')
});
});
</script>';
$text = $langs->trans("InvoiceReplacementAsk") . ' ';
$text = $tmp.$langs->trans("InvoiceReplacementAsk") . ' ';
$text .= '<select class="flat" name="fac_replacement" id="fac_replacement"';
if (! $options)
$text .= ' disabled';
@ -2172,20 +2172,19 @@ if ($action == 'create')
$text .= '<option value="-1">' . $langs->trans("NoReplacableInvoice") . '</option>';
}
$text .= '</select>';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1);
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</td></tr>' . "\n";
print '</div></div>';
}
else
{
print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" id="radio_replacement" value="0" disabled>';
print '</td><td valign="middle">';
$text = $langs->trans("InvoiceReplacement") . ' ';
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_replacement" value="0" disabled> ';
$text = $tmp.$langs->trans("InvoiceReplacement") . ' ';
$text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') ';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1);
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</td></tr>' . "\n";
print '</div></div>';
}
if (empty($origin))
@ -2193,12 +2192,10 @@ if ($action == 'create')
if ($socid > 0)
{
// Credit note
print '<tr height="18"><td valign="top">';
print '<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
if (! $optionsav)
print ' disabled';
print '>';
print '</td><td valign="top">';
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
if (! $optionsav) $tmp.=' disabled';
$tmp.= '> ';
// Show credit note options only if we checked credit note
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
@ -2214,7 +2211,7 @@ if ($action == 'create')
});
});
</script>';
$text = $langs->transnoentities("InvoiceAvoirAsk") . ' ';
$text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' ';
// $text.='<input type="text" value="">';
$text .= '<select class="flat" name="fac_avoir" id="fac_avoir"';
if (! $optionsav)
@ -2227,7 +2224,7 @@ if ($action == 'create')
$text .= '<option value="-1">' . $langs->trans("NoInvoiceToCorrect") . '</option>';
}
$text .= '</select>';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1);
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
print $desc;
print '<div id="credit_note_options">';
@ -2235,22 +2232,22 @@ if ($action == 'create')
print '<br>&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop("checked", true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '</div>';
print '</td></tr>' . "\n";
print '</div></div>';
}
else
{
print '<tr height="18"><td valign="middle">';
print '<input type="radio" name="type" id="radio_creditnote" value="0" disabled>';
print '</td><td valign="middle">';
$text = $langs->trans("InvoiceAvoir") . ' ';
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
$text = $tmp.$langs->trans("InvoiceAvoir") . ' ';
$text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') ';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1);
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</td></tr>' . "\n";
print '</div></div>' . "\n";
}
}
print '</table>';
print '</div>';
print '</td></tr>';
if ($socid > 0)
@ -2295,12 +2292,15 @@ if ($action == 'create')
print '</td></tr>';
// Project
if (! empty($conf->projet->enabled) && $socid > 0) {
$formproject = new FormProjets($db);
if (! empty($conf->projet->enabled) && $socid > 0)
{
$projectid = GETPOST('projectid')?GETPOST('projectid'):0;
if ($origin == 'project') $projectid = ($originid ? $originid : 0);
$langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
$formproject->select_projects($soc->id, $projectid, 'projectid', 0);
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
print ' &nbsp; <a href="../projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
print '</td></tr>';
}
@ -2322,7 +2322,7 @@ if ($action == 'create')
print $object->showOptionals($extrafields, 'edit');
}
// Modele PDF
// Template to use by default
print '<tr><td>' . $langs->trans('Model') . '</td>';
print '<td>';
include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
@ -2339,7 +2339,7 @@ if ($action == 'create')
{
$note_public = $objectsrc->note_public;
}
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
@ -2353,7 +2353,7 @@ if ($action == 'create')
{
$note_private = $objectsrc->note_private;
}
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
print '</td></tr>';
@ -2420,7 +2420,9 @@ if ($action == 'create')
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2) . "</td></tr>";
}
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>";
} else {
}
else
{
// Show deprecated optional form to add product line here
if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) {
print '<tr><td colspan="3">';
@ -2479,7 +2481,7 @@ if ($action == 'create')
// Button "Create Draft"
print '<div class="center">';
print '<input type="submit" class="button" name="bouton" value="' . $langs->trans('CreateDraft') . '">';
print '&nbsp; &nbsp; &nbsp;';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
print '</div>';
@ -3488,50 +3490,50 @@ if ($action == 'create')
// Show global modifiers
if (! empty($conf->global->INVOICE_US_SITUATION))
{
if ($object->situation_cycle_ref && $object->statut == 0) {
print '<tr class="liste_titre nodrag nodrop">';
print '<form name="updatealllines" id="updatealllines" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '"#updatealllines" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />';
print '<input type="hidden" name="action" value="updatealllines" />';
print '<input type="hidden" name="id" value="' . $object->id . '" />';
if ($object->situation_cycle_ref && $object->statut == 0) {
print '<tr class="liste_titre nodrag nodrop">';
print '<form name="updatealllines" id="updatealllines" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '"#updatealllines" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />';
print '<input type="hidden" name="action" value="updatealllines" />';
print '<input type="hidden" name="id" value="' . $object->id . '" />';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td align="center" width="5">&nbsp;</td>';
}
print '<td>' . $langs->trans('ModifyAllLines') . '</td>';
print '<td align="right" width="50">&nbsp;</td>';
print '<td align="right" width="80">&nbsp;</td>';
if ($inputalsopricewithtax) print '<td align="right" width="80">&nbsp;</td>';
print '<td align="right" width="50">&nbsp</td>';
print '<td align="right" width="50">&nbsp</td>';
print '<td align="right" width="50">' . $langs->trans('Progress') . '</td>';
if (! empty($conf->margin->enabled) && empty($user->societe_id))
{
print '<td align="right" class="margininfos" width="80">&nbsp;</td>';
if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $user->rights->margins->liretous) {
print '<td align="right" class="margininfos" width="50">&nbsp;</td>';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td align="center" width="5">&nbsp;</td>';
}
}
print '<td align="right" width="50">&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td width="10">&nbsp;</td>';
print '<td width="10">&nbsp;</td>';
print "</tr>\n";
print '<td>' . $langs->trans('ModifyAllLines') . '</td>';
print '<td align="right" width="50">&nbsp;</td>';
print '<td align="right" width="80">&nbsp;</td>';
if ($inputalsopricewithtax) print '<td align="right" width="80">&nbsp;</td>';
print '<td align="right" width="50">&nbsp</td>';
print '<td align="right" width="50">&nbsp</td>';
print '<td align="right" width="50">' . $langs->trans('Progress') . '</td>';
if (! empty($conf->margin->enabled) && empty($user->societe_id))
{
print '<td align="right" class="margininfos" width="80">&nbsp;</td>';
if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $user->rights->margins->liretous) {
print '<td align="right" class="margininfos" width="50">&nbsp;</td>';
}
}
print '<td align="right" width="50">&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td width="10">&nbsp;</td>';
print '<td width="10">&nbsp;</td>';
print "</tr>\n";
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td align="center" width="5">&nbsp;</td>';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td align="center" width="5">&nbsp;</td>';
}
print '<tr width="100%" class="nodrag nodrop">';
print '<td>&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td width="80">&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td align="right" class="nowrap"><input type="text" size="1" value="" name="all_progress">%</td>';
print '<td colspan="4" align="right"><input class="button" type="submit" name="all_percent" value="Modifier" /></td>';
print '</tr>';
print '</form>';
}
print '<tr width="100%" height="18" class="nodrag nodrop">';
print '<td>&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td width="80">&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td align="right" class="nowrap"><input type="text" size="1" value="" name="all_progress">%</td>';
print '<td colspan="4" align="right"><input class="button" type="submit" name="all_percent" value="Modifier" /></td>';
print '</tr>';
print '</form>';
}
}
// Show object lines
@ -3754,7 +3756,7 @@ if ($action == 'create')
}
print '<br>';
//Select mail models is same action as presend
// Select mail models is same action as presend
if (GETPOST('modelselected')) {
$action = 'presend';
}
@ -3774,77 +3776,10 @@ if ($action == 'create')
$somethingshown = $formfile->numoffiles;
// Linked object block
$somethingshown = $object->showLinkedObjectBlock();
$somethingshown = $form->showLinkedObjectBlock($object);
$linktoelem='';
if (! empty($conf->commande->enabled))
{
$linktoelem.=($linktoelem?' &nbsp; ':'').'<a href="#" id="linktoorder">' . $langs->trans('LinkedOrder') . '</a>';
print '
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#linktoorder").click(function() {
jQuery("#orderlist").toggle();
jQuery("#linktoorder").toggle();
});
});
</script>
';
print '<div id="orderlist" style="display:none">';
$sql = "SELECT s.rowid as socid, s.nom as name, s.client, c.rowid, c.ref, c.ref_client, c.total_ht";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "commande as c";
$sql .= ' WHERE c.fk_soc = s.rowid AND c.fk_soc = ' . $soc->id . '';
$resqlorderlist = $db->query($sql);
if ($resqlorderlist)
{
$num = $db->num_rows($resqlorderlist);
$i = 0;
print '<br><form action="" method="POST" name="LinkedOrder">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td class="nowrap"></td>';
print '<td align="center">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("RefCustomer") . '</td>';
print '<td align="left">' . $langs->trans("AmountHTShort") . '</td>';
print '<td align="left">' . $langs->trans("Company") . '</td>';
print '</tr>';
while ($i < $num)
{
$objp = $db->fetch_object($resqlorderlist);
if ($objp->socid == $soc->id) {
$var = ! $var;
print '<tr ' . $bc [$var] . '>';
print '<td aling="left">';
print '<input type="radio" name="linkedOrder" value=' . $objp->rowid . '>';
print '<td align="center">' . $objp->ref . '</td>';
print '<td>' . $objp->ref_client . '</td>';
print '<td>' . price($objp->total_ht) . '</td>';
print '<td>' . $objp->name . '</td>';
print '</td>';
print '</tr>';
}
$i ++;
}
print '</table>';
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('ToLink') . '"> &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
print '</form>';
$db->free($resqlorderlist);
} else {
dol_print_error($db);
}
print '</div>';
}
// Show link to elements
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print '<br>'.$linktoelem;
// Link for paypal payment
@ -3886,8 +3821,8 @@ if ($action == 'create')
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
@ -3911,14 +3846,16 @@ if ($action == 'create')
dol_print_error($db, $result);
exit();
}
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/'));
$file = $fileparams ['fullname'];
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<br>';
print_titre($langs->trans($titreform));
// Cree l'objet formulaire mail
dol_fiche_head();
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
@ -3990,7 +3927,7 @@ if ($action == 'create')
print $formmail->get_form();
print '<br>';
dol_fiche_end();
}
}

View File

@ -92,18 +92,16 @@ class Facture extends CommonInvoice
var $revenuestamp;
/**
* @deprecated
* @see note_private, note_public
*/
var $note;
var $note_private;
var $note_public;
/**
* Check constants for more info:
* - STATUS_DRAFT
* - STATUS_VALIDATED
* - STATUS_PAID
* - STATUS_ABANDONED
* Invoice status
* @var int
* @see Facture::STATUS_DRAFT, Facture::STATUS_VALIDATED, Facture::STATUS_PAID, Facture::STATUS_ABANDONED
*/
var $statut;
//! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon
@ -131,6 +129,9 @@ class Facture extends CommonInvoice
* @deprecated
*/
var $products=array();
/**
* @var FactureLigne[]
*/
var $lines=array();
var $line;
var $extraparams=array();
@ -1119,7 +1120,8 @@ class Facture extends CommonInvoice
$objp = $this->db->fetch_object($result);
$line = new FactureLigne($this->db);
$line->rowid = $objp->rowid;
$line->id = $objp->rowid;
$line->rowid = $objp->rowid; // deprecated
$line->label = $objp->custom_label; // deprecated
$line->desc = $objp->description; // Description line
$line->product_type = $objp->product_type; // Type of line
@ -2105,6 +2107,11 @@ class Facture extends CommonInvoice
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='', $fk_unit = null)
{
// Deprecation warning
if ($label) {
dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING);
}
global $mysoc, $conf, $langs;
dol_syslog(get_class($this)."::addline facid=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG);
@ -2289,6 +2296,11 @@ class Facture extends CommonInvoice
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null)
{
// Deprecation warning
if ($label) {
dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING);
}
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
global $mysoc;
@ -3203,7 +3215,7 @@ class Facture extends CommonInvoice
$response = new WorkboardResponse();
$response->warning_delay=$conf->facture->client->warning_delay/60/60/24;
$response->label=$langs->trans("CustomerBillsUnpaid");
$response->url=DOL_URL_ROOT.'/compta/facture/impayees.php';
$response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1';
$response->img=img_object($langs->trans("Bills"),"bill");
while ($obj=$this->db->fetch_object($resql))
@ -3685,7 +3697,10 @@ class FactureLigne extends CommonInvoiceLine
var $fk_facture;
//! Id parent line
var $fk_parent_line;
var $label; // deprecated
/**
* @deprecated
*/
var $label;
//! Description ligne
var $desc;
@ -3717,8 +3732,16 @@ class FactureLigne extends CommonInvoiceLine
//var $remise; // Montant calcule de la remise % sur PU HT (exemple 20)
// From llx_product
/**
* @deprecated
* @see product_ref
*/
var $ref; // Product ref (deprecated)
var $product_ref; // Product ref
/**
* @deprecated
* @see product_label
*/
var $libelle; // Product label (deprecated)
var $product_label; // Product label
var $product_desc; // Description produit

View File

@ -84,6 +84,8 @@ class FactureStats extends Stats
$this->where.=" AND f.fk_soc = ".$this->socid;
}
if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid;
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2)";
else $this->where.= " AND f.type IN (0,1,2,3)";
}
@ -206,7 +208,7 @@ class FactureStats extends Stats
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
$sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where;
$sql.= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid";
$sql.= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year,1,false))."' AND '".$this->db->idate(dol_get_last_day($year,12,false))."'";

View File

@ -37,6 +37,7 @@ $langs->load('propal');
$langs->load('compta');
$langs->load('other');
$langs->load("bills");
$langs->load('companies');
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility

View File

@ -2,10 +2,11 @@
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.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
@ -128,6 +129,8 @@ if ($action == 'create')
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="facid" value="'.$object->id.'">';
dol_fiche_head();
$rowspan=4;
if (! empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++;
@ -139,7 +142,7 @@ if ($action == 'create')
// Third party
print '<tr><td>'.$langs->trans("Customer").'</td><td>'.$object->client->getNomUrl(1,'customer').'</td>';
print '<td>';
//print $langs->trans("NotePrivate");
print $langs->trans("Comment");
print '</td></tr>';
// Title
@ -371,10 +374,15 @@ if ($action == 'create')
print '</select>';
print '</td></tr>';
}
print '<tr><td colspan="3" align="center"><br><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print "</form>\n";
print "</table>\n";
dol_fiche_end();
print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
print '</div>';
print "</form>\n";
}
else
{
@ -432,7 +440,7 @@ else
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id,'none');
print "</td></tr>";
print '<tr><td>'.$langs->trans("Note").'</td><td colspan="3">'.nl2br($object->note_private)."</td></tr>";
print '<tr><td>'.$langs->trans("Comment").'</td><td colspan="3">'.nl2br($object->note_private)."</td></tr>";
print "</table>";

View File

@ -10,6 +10,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
*
* 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
@ -88,6 +89,9 @@ $search_sale = GETPOST('search_sale','int');
$day = GETPOST('day','int');
$month = GETPOST('month','int');
$year = GETPOST('year','int');
$day_lim = GETPOST('day_lim','int');
$month_lim = GETPOST('month_lim','int');
$year_lim = GETPOST('year_lim','int');
$filtre = GETPOST('filtre');
// Security check
@ -213,6 +217,19 @@ else if ($year > 0)
{
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($month_lim > 0)
{
if ($year_lim > 0 && empty($day_lim))
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'";
else if ($year_lim > 0 && ! empty($day_lim))
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'";
else
$sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$month_lim."'";
}
else if ($year_lim > 0)
{
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'";
}
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
if ($search_user > 0)
{
@ -322,7 +339,11 @@ if ($resql)
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
print '<td class="liste_titre" align="left">&nbsp;</td>';
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.$day_lim.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_lim" value="'.$month_lim.'">';
$formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5);
print '</td>';
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.$search_societe.'"></td>';
print '<td class="liste_titre" align="right"><input class="flat" type="text" size="6" name="search_montant_ht" value="'.$search_montant_ht.'"></td>';
print '<td class="liste_titre" align="right">&nbsp;</td>';

View File

@ -275,7 +275,7 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
{
$arrayofinclusion=array();
foreach($_POST['toGenerate'] as $tmppdf) $arrayofinclusion[]=preg_quote($tmppdf.'.pdf','/');
$factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC);
$factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true);
// liste les fichiers
$files = array();
@ -284,7 +284,7 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
{
foreach($factures as $facture)
{
if(strstr($facture["name"],$basename))
if (strstr($facture["name"],$basename))
{
$files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"];
}

View File

@ -36,6 +36,7 @@ if (!$user->rights->facture->lire) accessforbidden();
$langs->load("bills");
$langs->load("banks");
$langs->load("withdrawals");
$langs->load('companies');
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha');
@ -396,7 +397,7 @@ if ($object->id > 0)
}
print "</td>";
print '</tr>';
// Montants
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2" class="nowrap">'.price($object->total_ht).'</td>';

View File

@ -775,7 +775,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsCustomersUnpaid",$num).' <a href="'.DOL_URL_ROOT.'/compta/facture/impayees.php"><span class="badge">'.$num.'</span></a></td>';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsCustomersUnpaid",$num).' <a href="'.DOL_URL_ROOT.'/compta/facture/list.php?search_status=1"><span class="badge">'.$num.'</span></a></td>';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td align="right">'.$langs->trans("AmountHT").'</td>';
print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
print '<td align="right">'.$langs->trans("Received").'</td>';

View File

@ -109,7 +109,7 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services
{
$nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code);
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");

View File

@ -129,7 +129,7 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services
{
$nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode");
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$prevyear=$year_start; $prevquarter=$q;
@ -161,7 +161,7 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice
if ($conf->global->$calc==2) // Invoice for goods, payment for services
{
$nom=$langs->trans($local==1?"LT1ReportByQuartersInInputOutputMode":"LT2ReportByQuartersInInputOutputMode");
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT'.$local.'Rec");
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$prevyear=$year_start; $prevquarter=$q;

View File

@ -6,7 +6,7 @@
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.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
@ -403,6 +403,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.'">';
print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->client->name).'">';
dol_fiche_head();
print '<table class="border" width="100%">';
// Third party
@ -462,6 +464,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '</table>';
dol_fiche_end();
/*
* List of unpaid invoices
*/

View File

@ -40,7 +40,16 @@ class Paiement extends CommonObject
var $ref;
var $facid;
var $datepaye;
var $total; // deprecated
/**
* @deprecated
* @see amount, amounts
*/
var $total;
/**
* @deprecated
* @see amount, amounts
*/
var $montant;
var $amount; // Total amount of payment
var $amounts=array(); // Array of amounts
var $author;

View File

@ -0,0 +1,136 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/compta/salaries/document.php
* \ingroup salaries
* \brief Page of linked files onto salaries
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
$langs->load("other");
$langs->load("salaries");
$langs->load("companies");
$id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'salaries', $id, '');
// Get parameters
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$object = new PaymentSalary($db);
$object->fetch($id, $ref);
$upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id);
$modulepart='salaries';
/*
* Actions
*/
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
* View
*/
$form = new Form($db);
llxHeader("","",$langs->trans("SalaryPayment"));
if ($object->id)
{
$object->fetch_thirdparty();
$head=salaries_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans("SalaryPayment"), 0, 'payment');
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/salaries/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print '</td></tr>';
// Societe
//print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
$modulepart = 'salaries';
$permission = $user->rights->salaries->write;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
{
print $langs->trans("ErrorUnknown");
}
llxFooter();
$db->close();

View File

@ -501,7 +501,7 @@ if ($id > 0)
}
// Emettre paiement
if ($object->paye == 0 && ((price2num($object->amount) < 0 && round($resteapayer) < 0) || (price2num($object->amount) > 0 && round($resteapayer) > 0)) && $user->rights->tax->charges->creer)
if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer)
{
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/paiement_charge.php?id=$object->id&amp;action=create\">".$langs->trans("DoPayment")."</a>";
}

View File

@ -40,6 +40,11 @@ class PaymentSocialContribution extends CommonObject
var $datec='';
var $tms='';
var $datep='';
/**
* @deprecated
* @see amount
*/
var $total;
var $amount; // Total amount of payment
var $amounts=array(); // Array of amounts
var $fk_typepaiement;

View File

@ -51,6 +51,8 @@ abstract class ActionsContactCardCommon
*/
private function getInstanceDao()
{
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
if (! is_object($this->object))
{
$modelclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/dao_'.$this->targetmodule.'_'.$this->canvas.'.class.php');

View File

@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT. '/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$langs->load("companies");
$langs->load("users");
$langs->load("other");
@ -201,7 +202,11 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++;
if ($ret < 0)
{
$error++;
$action = 'create';
}
if (! GETPOST("lastname"))
{
@ -216,7 +221,17 @@ if (empty($reshook))
{
$error++; $errors=array_merge($errors,($object->error?array($object->error):$object->errors));
$action = 'create';
}
} else {
// Categories association
$contcats = GETPOST( 'contcats', 'array' );
if (!empty( $contcats )) {
$cat = new Categorie( $db );
foreach ($contcats as $id_category) {
$cat->fetch( $id_category );
$cat->add_type( $object, 'contact' );
}
}
}
}
if (! $error && $id > 0)
@ -309,8 +324,22 @@ if (empty($reshook))
$result = $object->update($contactid, $user);
if ($result > 0)
{
if ($result > 0) {
// Categories association
// First we delete all categories association
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_contact';
$sql .= ' WHERE fk_socpeople = ' . $object->id;
$db->query( $sql );
// Then we add the associated categories
$categories = GETPOST( 'contcats', 'array' );
if (!empty( $categories )) {
$cat = new Categorie( $db );
foreach ($categories as $id_category) {
$cat->fetch( $id_category );
$cat->add_type( $object, 'contact' );
}
}
$object->old_lastname='';
$object->old_firstname='';
$action = 'view';
@ -576,6 +605,15 @@ else
print $form->selectarray('priv',$selectarray,(GETPOST("priv",'alpha')?GETPOST("priv",'alpha'):$object->priv),0);
print '</td></tr>';
// Categories
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) {
print '<tr><td>' . fieldLabel( 'Categories', 'contcats' ) . '</td><td colspan="3">';
$cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, 'parent', null, null, 1 );
print $form->multiselectarray( 'contcats', $cate_arbo, GETPOST( 'contcats', 'array' ), null, null, null,
null, '90%' );
print "</td></tr>";
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@ -815,6 +853,20 @@ else
print $object->getLibStatut(4);
print '</td></tr>';
// Categories
if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) {
print '<tr><td>' . fieldLabel( 'Categories', 'contcats' ) . '</td>';
print '<td colspan="3">';
$cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, null, null, null, 1 );
$c = new Categorie( $db );
$cats = $c->containing( $object->id, Categorie::TYPE_CONTACT );
foreach ($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray( 'contcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%' );
print "</td></tr>";
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@ -1039,6 +1091,15 @@ else
print $object->getLibStatut(4);
print '</td>';
print '</tr>'."\n";
// Categories
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) {
print '<tr><td>' . $langs->trans( "Categories" ) . '</td>';
print '<td colspan="3">';
print $form->showCategories( $object->id, 'contact', 1 );
print '</td></tr>';
}
// Other attributes
$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@ -1101,18 +1162,14 @@ else
{
if ($user->rights->societe->contact->creer)
{
print '<a class="butAction" href="card.php?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a>';
}
if (! $object->user_id && $user->rights->user->user->creer)
{
print '<a class="butAction" href="card.php?id='.$object->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
}
if ($user->rights->societe->contact->supprimer)
{
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete'.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.$langs->trans('Delete').'</a>';
}
// Activer
if ($object->statut == 0 && $user->rights->societe->contact->creer)
{
@ -1122,6 +1179,12 @@ else
if ($object->statut == 1 && $user->rights->societe->contact->creer)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=disable&id='.$object->id.'">'.$langs->trans("DisableUser").'</a>';
}
// Delete
if ($user->rights->societe->contact->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete'.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.$langs->trans('Delete').'</a>';
}
}

View File

@ -50,9 +50,21 @@ class Contact extends CommonObject
var $zip;
var $town;
var $fk_departement; // deprecated
var $departement_code; // deprecated
var $departement; // deprecated
/**
* @deprecated
* @see state_id
*/
var $fk_departement;
/**
* @deprecated
* @see state_code
*/
var $departement_code;
/**
* @deprecated
* @see state
*/
var $departement;
var $state_id; // Id of department
var $state_code; // Code of department
var $state; // Label of department
@ -80,7 +92,11 @@ class Contact extends CommonObject
var $birthday;
var $default_lang;
var $note_public; // Public note
var $note; // deprecated
/**
* @deprecated
* @see note_public, note_private
*/
var $note;
var $note_private; // Private note
var $no_email; // 1=Don't send e-mail to this contact, 0=do
@ -629,6 +645,13 @@ class Contact extends CommonObject
}
}
// Retreive all extrafield for contact
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
return 1;
}
else
@ -895,6 +918,11 @@ class Contact extends CommonObject
$result='';
$label = '<u>' . $langs->trans("ShowContact") . '</u>';
$label.= '<br><b>' . $langs->trans("Name") . ':</b> '.$this->getFullName($langs);
//if ($this->cibility_id) $label.= '<br><b>' . $langs->trans("Civility") . ':</b> '.$this->civility_id; // TODO Translate cibilty_id code
$label.= '<br><b>' . $langs->trans("Poste") . ':</b> '.$this->poste;
$label.= '<br><b>' . $langs->trans("EMail") . ':</b> '.$this->email;
$label.= '<br><b>' . $langs->trans("Phone") . ':</b> '.join(', ',array($this->phone_pro,$this->phone_mobile,$this->phone_perso));
$label.= '<br><b>' . $langs->trans("Address") . ':</b> '.dol_format_address($this, 1, ' ', $langs);
$link = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
@ -1101,4 +1129,4 @@ class Contact extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
}
}

View File

@ -80,8 +80,9 @@ llxHeader("",$langs->trans("Contact"), $helpurl);
if ($object->id)
{
$head = contact_prepare_head($object);
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
dol_fiche_head($head, 'documents', $langs->trans("Contact"), 0, 'contact');
dol_fiche_head($head, 'documents', $title, 0, 'contact');
// Construit liste des fichiers

View File

@ -159,7 +159,7 @@ else
if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")";
}
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_firstlast_only) {
@ -256,11 +256,11 @@ if ($result)
{
$contactstatic=new Contact($db);
$param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall);
$param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email);
if (!empty($search_categ)) $param.='&search_categ='.$search_categ;
if ($search_status != '') $param.='&amp;search_status='.$search_status;
if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv);
$param ='&begin='.htmlspecialchars($begin).'&view='.htmlspecialchars($view).'&userid='.htmlspecialchars($userid).'&contactname='.htmlspecialchars($sall);
$param.='&type='.htmlspecialchars($type).'&view='.htmlspecialchars($view).'&search_lastname='.htmlspecialchars($search_lastname).'&search_firstname='.htmlspecialchars($search_firstname).'&search_societe='.htmlspecialchars($search_societe).'&search_email='.htmlspecialchars($search_email);
if (!empty($search_categ)) $param.='&search_categ='.htmlspecialchars($search_categ);
if ($search_status != '') $param.='&amp;search_status='.htmlspecialchars($search_status);
if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".htmlspecialchars($search_priv);
$num = $db->num_rows($result);
$i = 0;
@ -269,7 +269,7 @@ if ($result)
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="view" value="'.$view.'">';
print '<input type="hidden" name="view" value="'.htmlspecialchars($view).'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
@ -317,36 +317,36 @@ if ($result)
// Ligne des champs de filtres
print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_lastname" size="9" value="'.$search_lastname.'">';
print '<input class="flat" type="text" name="search_lastname" size="9" value="'.dol_escape_htmltag($search_lastname).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_firstname" size="9" value="'.$search_firstname.'">';
print '<input class="flat" type="text" name="search_firstname" size="9" value="'.dol_escape_htmltag($search_firstname).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_poste" size="9" value="'.$search_poste.'">';
print '<input class="flat" type="text" name="search_poste" size="9" value="'.dol_escape_htmltag($search_poste).'">';
print '</td>';
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_societe" size="9" value="'.$search_societe.'">';
print '<input class="flat" type="text" name="search_societe" size="9" value="'.dol_escape_htmltag($search_societe).'">';
print '</td>';
}
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_phonepro" size="8" value="'.$search_phonepro.'">';
print '<input class="flat" type="text" name="search_phonepro" size="8" value="'.dol_escape_htmltag($search_phonepro).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_phonemob" size="8" value="'.$search_phonemob.'">';
print '<input class="flat" type="text" name="search_phonemob" size="8" value="'.dol_escape_htmltag($search_phonemob).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_fax" size="8" value="'.$search_fax.'">';
print '<input class="flat" type="text" name="search_fax" size="8" value="'.dol_escape_htmltag($search_fax).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_email" size="8" value="'.$search_email.'">';
print '<input class="flat" type="text" name="search_email" size="8" value="'.dol_escape_htmltag($search_email).'">';
print '</td>';
if (! empty($conf->skype->enabled))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="search_skype" size="8" value="'.$search_skype.'">';
print '<input class="flat" type="text" name="search_skype" size="8" value="'.dol_escape_htmltag($search_skype).'">';
print '</td>';
}
print '<td class="liste_titre">&nbsp;</td>';

View File

@ -823,10 +823,8 @@ else if ($action == 'remove_file' && $user->rights->contrat->creer) {
$upload_dir = $conf->contrat->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret)
setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
else
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
}
}
@ -1873,10 +1871,13 @@ else
$somethingshown = $formfile->show_documents('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
/*
* Linked object block
*/
$somethingshown=$object->showLinkedObjectBlock();
// Linked object block
$somethingshown = $form->showLinkedObjectBlock($object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object);
if ($linktoelem) print '<br>'.$linktoelem;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -154,6 +154,7 @@ class Contrat extends CommonObject
/**
* @deprecated Use fk_project instead
* @see fk_project
*/
var $fk_projet;
@ -1642,6 +1643,8 @@ class Contrat extends CommonObject
*/
function update_statut($user)
{
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
// If draft, we keep it (should not happen)
if ($this->statut == 0) return 1;
@ -2165,6 +2168,7 @@ class ContratLigne extends CommonObjectLine
/**
* @var string
* @deprecated Use $label instead
* @see label
*/
public $libelle;
@ -2189,6 +2193,7 @@ class ContratLigne extends CommonObjectLine
/**
* @var float
* @deprecated Use $price_ht instead
* @see price_ht
*/
public $price;

View File

@ -100,7 +100,8 @@ $sql.= ", ".MAIN_DB_PREFIX."contrat as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql.= " WHERE c.fk_soc = s.rowid ";
$sql.= " AND c.entity = ".$conf->entity;
if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($socid) $sql.= " AND s.rowid = ".$db->escape($socid);
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($search_name) {
$sql .= natural_search('s.nom', $search_name);
@ -112,7 +113,7 @@ if (!empty($search_ref_supplier)) {
$sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier);
}
if ($search_sale > 0)
if ($search_sale > 0)
{
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
}
@ -131,7 +132,7 @@ if ($resql)
$i = 0;
print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], '&search_contract='.$search_contract.'&search_name='.$search_name, $sortfield, $sortorder,'',$num,$totalnboflines,'title_commercial.png');
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<table class="liste" width="100%">';
@ -144,7 +145,7 @@ if ($resql)
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
}
if ($moreforfilter)
{
print '<tr class="liste_titre">';
@ -152,13 +153,14 @@ if ($resql)
print $moreforfilter;
print '</td></tr>';
}
print '<tr class="liste_titre">';
$param='&amp;search_contract='.$search_contract;
$param.='&amp;search_name='.$search_name;
$param.='&amp;search_ref_supplier='.$search_ref_supplier;
$param='&search_contract='.$search_contract;
$param.='&search_name='.$search_name;
$param.='&search_ref_supplier='.$search_ref_supplier;
$param.='&search_sale=' .$search_sale;
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("RefCustomer"), $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder);
@ -175,13 +177,13 @@ if ($resql)
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="3" name="search_contract" value="'.$search_contract.'">';
print '<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="7" name="search_ref_supplier value="'.$search_ref_supplier.'">';
print '<input type="text" class="flat" size="7" name="search_ref_supplier value="'.dol_escape_htmltag($search_ref_supplier).'">';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="24" name="search_name" value="'.$search_name.'">';
print '<input type="text" class="flat" size="24" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
print '</td>';
print '<td class="liste_titre">&nbsp;</td>';
//print '<td class="liste_titre">&nbsp;</td>';
@ -202,7 +204,7 @@ if ($resql)
print '<td>'.$obj->ref_supplier.'</td>';
print '<td><a href="../comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
//print '<td align="center">'.dol_print_date($obj->datec).'</td>';
// Sales Rapresentatives
print '<td>';
if($obj->socid)
@ -237,8 +239,8 @@ if ($resql)
print '&nbsp';
}
print '</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->date_contrat)).'</td>';
//print '<td align="center">'.$staticcontrat->LibStatut($obj->statut,3).'</td>';
print '<td align="center">'.($obj->nb_initial>0?$obj->nb_initial:'').'</td>';

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2011-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2011-2015 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
@ -148,7 +148,21 @@ if ($action == 'add')
}
}
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params,(GETPOST('alwayseditable')?1:0));
$result=$extrafields->addExtraField(
GETPOST('attrname'),
GETPOST('label'),
GETPOST('type'),
GETPOST('pos'),
$extrasize,
$elementtype,
(GETPOST('unique')?1:0),
(GETPOST('required')?1:0),
$default_value,
$params,
(GETPOST('alwayseditable')?1:0),
(GETPOST('perms')?GETPOST('perms'):''),
(GETPOST('list')?1:0)
);
if ($result > 0)
{
setEventMessage($langs->trans('SetupSaved'));
@ -285,7 +299,20 @@ if ($action == 'update')
$params['options'][$key] = $value;
}
}
$result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$pos,$params,(GETPOST('alwayseditable')?1:0));
$result=$extrafields->update(
GETPOST('attrname'),
GETPOST('label'),
GETPOST('type'),
$extrasize,
$elementtype,
(GETPOST('unique')?1:0),
(GETPOST('required')?1:0),
$pos,
$params,
(GETPOST('alwayseditable')?1:0),
(GETPOST('perms')?GETPOST('perms'):''),
(GETPOST('list')?1:0)
);
if ($result > 0)
{
setEventMessage($langs->trans('SetupSaved'));

View File

@ -37,7 +37,7 @@
class CMailFile
{
var $subject; // Topic: Subject of email
var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@mydomain.com>' or 'John Doe <myemail@mydomain.com>' or '<myemail+trackingid@mydomain.com>')
var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>')
// Sender: Who send the email ("Sender" has sent emails on behalf of "From").
// Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, use for Sender an email of the protected domain.
// Return-Path: Email where to send bounds.
@ -387,7 +387,7 @@ class CMailFile
// If Windows, sendmail_from must be defined
if (isset($_SERVER["WINDIR"]))
{
if (empty($this->addr_from)) $this->addr_from = 'robot@mydomain.com';
if (empty($this->addr_from)) $this->addr_from = 'robot@example.com';
@ini_set('sendmail_from',$this->getValidAddress($this->addr_from,2));
}

View File

@ -118,6 +118,7 @@ abstract class CommonDocGenerator
'mycompany_idprof5'=>$mysoc->idprof5,
'mycompany_idprof6'=>$mysoc->idprof6,
'mycompany_vatnumber'=>$mysoc->tva_intra,
'mycompany_object'=>$mysoc->object,
// Only private not exists for "mysoc"
'mycompany_note_private'=>$mysoc->note_private,

View File

@ -7,7 +7,7 @@
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2011-2014 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -44,6 +44,7 @@ abstract class CommonObject
/**
* @var string Error string
* @deprecated Use instead the array of error strings
* @see errors
*/
public $error;
@ -82,7 +83,7 @@ abstract class CommonObject
public $errors=array();
/**
* @var string Can be used to pass information when only object is provided to method
* @var string[] Can be used to pass information when only object is provided to method
*/
public $context=array();
@ -96,7 +97,24 @@ abstract class CommonObject
public $lastname;
public $firstname;
public $civility_id;
/**
* @deprecated
* @see thirdparty
*/
public $client;
/**
* @var Societe
*/
public $thirdparty;
/**
* @deprecated
* @see project
*/
public $projet;
/**
* @var Project
*/
public $project;
// No constructor as it is an abstract class
@ -113,13 +131,15 @@ abstract class CommonObject
*/
static function isExistingObject($element, $id, $ref='', $ref_ext='')
{
global $db;
global $db,$conf;
$sql = "SELECT rowid, ref, ref_ext";
$sql.= " FROM ".MAIN_DB_PREFIX.$element;
if ($id > 0) $sql.= " WHERE rowid = ".$db->escape($id);
else if ($ref) $sql.= " WHERE ref = '".$db->escape($ref)."'";
else if ($ref_ext) $sql.= " WHERE ref_ext = '".$db->escape($ref_ext)."'";
$sql.= " WHERE entity IN (".getEntity($element).")" ;
if ($id > 0) $sql.= " AND rowid = ".$db->escape($id);
else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'";
else if ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'";
else {
$error='ErrorWrongParameters';
dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR);
@ -525,9 +545,9 @@ abstract class CommonObject
* Return array with list of possible values for type of contacts
*
* @param string $source 'internal', 'external' or 'all'
* @param string $order Sort order by : 'code' or 'rowid'
* @param string $option 0=Return array id->label, 1=Return array code->label
* @param string $activeonly 0=all status of contact, 1=only the active
* @param string $order Sort order by 'code' or 'rowid'
* @param int $option 0=Return array id->label, 1=Return array code->label
* @param int $activeonly 0=all status of contact, 1=only the active
* @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE')
* @return array Array list of type of contacts (id->label if option=0, code->label if option=1)
*/
@ -541,7 +561,7 @@ abstract class CommonObject
$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE tc.element='".$this->element."'";
if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active type
if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active types
if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$source."'";
if (! empty($code)) $sql.= " AND tc.code='".$code."'";
$sql.= " ORDER by tc.".$order;
@ -626,12 +646,12 @@ abstract class CommonObject
}
/**
* Charge le contact d'id $id dans this->contact
* Load object contact with id=$this->contactid into $this->contact
*
* @param int $contactid Id du contact. Use this->contactid if empty.
* @return int <0 if KO, >0 if OK
*/
function fetch_contact($contactid='')
function fetch_contact($contactid=null)
{
if (empty($contactid)) $contactid=$this->contactid;
@ -759,10 +779,14 @@ abstract class CommonObject
*/
function fetch_projet()
{
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (empty($this->fk_project) && ! empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility
if (empty($this->fk_project)) return 0;
$project = new Project($this->db);
$result = $project->fetch($this->fk_project);
$this->projet = $project; // deprecated
$this->project = $project;
return $result;
@ -858,14 +882,14 @@ abstract class CommonObject
/**
* Update a specific field into database
*
* @param string $field Field to update
* @param mixed $value New value
* @param string $table To force other table element or element line (should not be used)
* @param int $id To force other object id (should not be used)
* @param string $format Data format ('text', 'date'). 'text' is used if not defined
* @param string $id_field To force rowid field name. 'rowid' is used it not defined
* @param string $user Update last update fields also if user object provided
* @return int <0 if KO, >0 if OK
* @param string $field Field to update
* @param mixed $value New value
* @param string $table To force other table element or element line (should not be used)
* @param int $id To force other object id (should not be used)
* @param string $format Data format ('text', 'date'). 'text' is used if not defined
* @param string $id_field To force rowid field name. 'rowid' is used it not defined
* @param User|string $user Update last update fields also if user object provided
* @return int <0 if KO, >0 if OK
*/
function setValueFrom($field, $value, $table='', $id='', $format='', $id_field='', $user='')
{
@ -1639,9 +1663,10 @@ abstract class CommonObject
/**
* Update public note (kept for backward compatibility)
*
* @param string $note New value for note
* @return int <0 if KO, >0 if OK
* @deprecated
* @param string $note New value for note
* @return int <0 if KO, >0 if OK
* @deprecated
* @see update_note()
*/
function update_note_public($note)
{
@ -1655,10 +1680,10 @@ abstract class CommonObject
* @param int $exclspec >0 = Exclude special product (product_type=9)
* @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total
* @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
* @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object. For this, we need seller object.
* @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object and for this, we need seller object.
* @return int <0 if KO, >0 if OK
*/
function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller='')
function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller=null)
{
global $conf;
@ -2555,88 +2580,19 @@ abstract class CommonObject
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions
// --------------------
/* This is to show linked object block */
/**
* Show linked object block
* TODO Move this into html.class.php
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* Show linked object block.
*
* @return int
* @return int <0 if KO, >0 if OK
* @deprecated 3.8 Use instead $form->shoLinkedObjectBlock($object)
*/
function showLinkedObjectBlock()
{
global $conf,$langs,$hookmanager;
global $bc;
$this->fetchObjectLinked();
// Bypass the default method
$hookmanager->initHooks(array('commonobject'));
$parameters=array();
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
$num = count($this->linkedObjects);
foreach($this->linkedObjects as $objecttype => $objects)
{
$tplpath = $element = $subelement = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
$tplpath = $element.'/'.$subelement;
}
// To work with non standard path
if ($objecttype == 'facture') {
$tplpath = 'compta/'.$element;
if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'propal') {
$tplpath = 'comm/'.$element;
if (empty($conf->propal->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'askpricesupplier') {
$tplpath = 'comm/'.$element;
if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'shipping' || $objecttype == 'shipment') {
$tplpath = 'expedition';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'delivery') {
$tplpath = 'livraison';
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
}
else if ($objecttype == 'invoice_supplier') {
$tplpath = 'fourn/facture';
}
else if ($objecttype == 'order_supplier') {
$tplpath = 'fourn/commande';
}
global $linkedObjectBlock;
$linkedObjectBlock = $objects;
// Output template part (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/linkedobjectblock.tpl.php');
if ($res) break;
}
}
return $num;
}
global $form;
return $form->showLinkedObjectBlock($this);
}
/* This is to show add lines */
/**
@ -2684,9 +2640,9 @@ abstract class CommonObject
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
*
* @param string $action Action code
* @param string $seller Object of seller third party
* @param string $buyer Object of buyer third party
* @param string $selected Object line selected
* @param Societe $seller Object of seller third party
* @param Societe $buyer Object of buyer third party
* @param int $selected Object line selected
* @param int $dateSelector 1=Show also date range input fields
* @return void
*/
@ -2799,16 +2755,16 @@ abstract class CommonObject
* Return HTML content of a detail line
* TODO Move this into an output class file (htmlline.class.php)
*
* @param string $action GET/POST action
* @param CommonObjectLine $line Selected object line to output
* @param string $var Is it a an odd line (true)
* @param int $num Number of line (0)
* @param int $i I
* @param int $dateSelector 1=Show also date range input fields
* @param string $seller Object of seller third party
* @param string $buyer Object of buyer third party
* @param string $selected Object line selected
* @param object $extrafieldsline Object of extrafield line attribute
* @param string $action GET/POST action
* @param CommonObjectLine $line Selected object line to output
* @param string $var Is it a an odd line (true)
* @param int $num Number of line (0)
* @param int $i I
* @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object of seller third party
* @param Societe $buyer Object of buyer third party
* @param int $selected Object line selected
* @param object $extrafieldsline Object of extrafield line attribute
* @return void
*/
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0)
@ -3083,228 +3039,24 @@ abstract class CommonObject
}
/**
* get Margin info
*
* @param string $force_price True of not
* @return mixed Array with info
*/
function getMarginInfos($force_price=false)
{
global $conf;
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$marginInfos = array(
'pa_products' => 0,
'pv_products' => 0,
'margin_on_products' => 0,
'margin_rate_products' => '',
'mark_rate_products' => '',
'pa_services' => 0,
'pv_services' => 0,
'margin_on_services' => 0,
'margin_rate_services' => '',
'mark_rate_services' => '',
'pa_total' => 0,
'pv_total' => 0,
'total_margin' => 0,
'total_margin_rate' => '',
'total_mark_rate' => ''
);
foreach($this->lines as $line) {
if (empty($line->pa_ht) && isset($line->fk_fournprice) && !$force_price) {
$product = new ProductFournisseur($this->db);
if ($product->fetch_product_fournisseur_price($line->fk_fournprice))
$line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100);
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0)
$line->pa_ht += $product->fourn_unitcharges;
}
// si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente
if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) {
$line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100));
}
// calcul des marges
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit
$marginInfos['pa_products'] += $pa;
$marginInfos['pv_products'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_products'] += $pv - $pa;
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service
$marginInfos['pa_services'] += $pa;
$marginInfos['pv_services'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_services'] += $pv - $pa;
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
}
}
else {
$type=$line->product_type?$line->product_type:$line->fk_product_type;
if ($type == 0) { // product
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pa_products'] += $pa;
$marginInfos['pv_products'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_products'] += $pv - $pa;
}
elseif ($type == 1) { // service
$pa = $line->qty * $line->pa_ht;
$pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pa_services'] += $pa;
$marginInfos['pv_services'] += $pv;
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($pv < 0)
$marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
else
$marginInfos['margin_on_services'] += $pv - $pa;
}
}
}
if ($marginInfos['pa_products'] > 0)
$marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products'];
if ($marginInfos['pv_products'] > 0)
$marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products'];
if ($marginInfos['pa_services'] > 0)
$marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services'];
if ($marginInfos['pv_services'] > 0)
$marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services'];
// if credit note, margin = -1 * (abs(selling_price) - buying_price)
if ($marginInfos['pv_total'] < 0)
$marginInfos['total_margin'] = -1 * (abs($marginInfos['pv_total']) - $marginInfos['pa_total']);
else
$marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
if ($marginInfos['pa_total'] > 0)
$marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total'];
if ($marginInfos['pv_total'] > 0)
$marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total'];
return $marginInfos;
}
/**
* Show the array with all margin infos
*
* @param string $force_price Force price
* @return void
* @param boolean $force_price Force price
* @return void
* @deprecated 3.8 Load FormMargin class and make a direct call to displayMarginInfos
*/
function displayMarginInfos($force_price=false)
{
global $langs, $conf, $user;
if (! empty($user->societe_id)) return;
if (! $user->rights->margins->liretous) return;
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
$marginInfo = $this->getMarginInfos($force_price);
if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
{
print $langs->trans('ShowMarginInfos').' : ';
$hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW'];
print '<span id="showMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'':'hideobject').'">'.img_picto($langs->trans("Disabled"),'switch_off').'</span>';
print '<span id="hideMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'hideobject':'').'">'.img_picto($langs->trans("Enabled"),'switch_on').'</span>';
print '<script>$(document).ready(function() {
$("span#showMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 0); $(".margininfos").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject");})});
$("span#hideMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 1); $(".margininfos").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject");})});
});</script>';
if (!empty($hidemargininfos)) print '<script>$(document).ready(function() {$(".margininfos").hide();});</script>';
}
print '<table class="nobordernopadding margintable" width="100%">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans('Margins').'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans('SellingPrice').'</td>';
if ($conf->global->MARGIN_TYPE == "1")
print '<td class="liste_titre" align="right">'.$langs->trans('BuyingPrice').'</td>';
else
print '<td class="liste_titre" align="right">'.$langs->trans('CostPrice').'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans('Margin').'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td class="liste_titre" align="right">'.$langs->trans('MarginRate').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td class="liste_titre" align="right">'.$langs->trans('MarkRate').'</td>';
print '</tr>';
if (! empty($conf->product->enabled))
{
//if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) {
print '<tr class="impair">';
print '<td>'.$langs->trans('MarginOnProducts').'</td>';
print '<td align="right">'.price($marginInfo['pv_products'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_products'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
if (! empty($conf->service->enabled))
{
print '<tr class="pair">';
print '<td>'.$langs->trans('MarginOnServices').'</td>';
print '<td align="right">'.price($marginInfo['pv_services'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_services'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
if (! empty($conf->product->enabled) && ! empty($conf->service->enabled))
{
print '<tr class="impair">';
print '<td>'.$langs->trans('TotalMargin').'</td>';
print '<td align="right">'.price($marginInfo['pv_total'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['pa_total'], null, null, null, null, $rounding).'</td>';
print '<td align="right">'.price($marginInfo['total_margin'], null, null, null, null, $rounding).'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'</td>';
print '</tr>';
}
print '</table>';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
$formmargin=new FormMargin($this->db);
$formmargin->displayMarginInfos($this, $force_price);
}
/**
* Add resources to the current object : add entry into llx_element_resources
*Need $this->element & $this->id
* Need $this->element & $this->id
*
* @param int $resource_id Resource id
* @param string $resource_element Resource element
@ -3726,7 +3478,7 @@ abstract class CommonObject
{
$attributeKey = substr($key,8); // Remove 'options_' prefix
$attributeType = $extrafields->attribute_type[$attributeKey];
$attributeSize = $extrafields->attribute_size[$attributeKey];
//$attributeSize = $extrafields->attribute_size[$attributeKey]; Not required to insert an extrafield value. Only used for definition.
$attributeLabel = $extrafields->attribute_label[$attributeKey];
$attributeParam = $extrafields->attribute_param[$attributeKey];
switch ($attributeType)
@ -3751,19 +3503,19 @@ abstract class CommonObject
case 'datetime':
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
break;
case 'link':
$param_list=array_keys($attributeParam ['options']);
// 0 : ObjectName
// 1 : classPath
$InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db);
if ($value)
{
$object->fetch(0,$value);
$this->array_options[$key]=$object->id;
}
break;
case 'link':
$param_list=array_keys($attributeParam ['options']);
// 0 : ObjectName
// 1 : classPath
$InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db);
if ($value)
{
$object->fetch(0,$value);
$this->array_options[$key]=$object->id;
}
break;
}
}
$this->db->begin();
@ -3771,6 +3523,7 @@ abstract class CommonObject
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
$this->db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
foreach($this->array_options as $key => $value)
{
@ -3825,7 +3578,7 @@ abstract class CommonObject
*
* @return string
*/
function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='')
function showOptionals($extrafields, $mode='view', $params=null, $keyprefix='')
{
global $_POST, $conf;
@ -3955,15 +3708,16 @@ abstract class CommonObject
* This function is meant to be called from replaceThirdparty with the appropiate tables
* Column name fk_soc MUST be used to identify thirdparties
*
* @param DoliDB $db Database handler
* @param int $origin_id Old thirdparty id
* @param int $dest_id New thirdparty id
* @param array $tables Tables that need to be changed
* @param DoliDB $db Database handler
* @param int $origin_id Old thirdparty id (the thirdparty to delete)
* @param int $dest_id New thirdparty id (the thirdparty that will received element of the other)
* @param array $tables Tables that need to be changed
* @return bool
*/
public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables)
{
foreach ($tables as $table) {
foreach ($tables as $table)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.$dest_id.' WHERE fk_soc = '.$origin_id;
if (!$db->query($sql)) {

View File

@ -39,6 +39,7 @@ abstract class CommonObjectLine extends CommonObject
* Id of the line
* @var int
* @deprecated Try to use id property as possible (even if field into database is still rowid)
* @see id
*/
public $rowid;

View File

@ -43,6 +43,7 @@ abstract class CommonOrderLine extends CommonObjectLine
* Product ref
* @var string
* @deprecated Use product_ref
* @see product_ref
*/
public $ref;
@ -56,6 +57,7 @@ abstract class CommonOrderLine extends CommonObjectLine
* Product label
* @var string
* @deprecated Use product_label
* @see product_label
*/
public $libelle;
@ -78,7 +80,9 @@ abstract class CommonOrderLine extends CommonObjectLine
public $qty;
/**
* Unit price
* @deprecated
* @see subprice
*/
var $price;

View File

@ -404,7 +404,7 @@ class Conf
$this->css = "/theme/".$this->theme."/style.css.php";
// conf->email_from = email pour envoi par dolibarr des mails automatiques
$this->email_from = "robot@domain.com";
$this->email_from = "robot@example.com";
if (! empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
// conf->notification->email_from = email pour envoi par Dolibarr des notifications

View File

@ -91,7 +91,14 @@ class dolprintIPP
}
}
// Getting Jobs
$ipp->getJobs(false,0,'completed',false);
try {
$ipp->getJobs(false,0,'completed',false); // May return errors if setup not correct
}
catch(Exception $e)
{
print $e->getMessage();
}
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print "<td>Id</td>";
@ -102,19 +109,22 @@ class dolprintIPP
print "<td>Cancel</td>";
print "</tr>\n";
$jobs = $ipp->jobs_attributes;
$var = True;
$var = true;
//print '<pre>'.print_r($jobs,true).'</pre>';
foreach ($jobs as $value )
if (is_array($jobs))
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.$value->job_id->_value0.'</td>';
print '<td>'.$value->job_originating_user_name->_value0.'</td>';
print '<td>'.$value->printer_uri->_value0.'</td>';
print '<td>'.$value->job_name->_value0.'</td>';
print '<td>'.$value->job_state->_value0.'</td>';
print '<td>'.$value->job_uri->_value0.'</td>';
print '</tr>';
foreach ($jobs as $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.$value->job_id->_value0.'</td>';
print '<td>'.$value->job_originating_user_name->_value0.'</td>';
print '<td>'.$value->printer_uri->_value0.'</td>';
print '<td>'.$value->job_name->_value0.'</td>';
print '<td>'.$value->job_state->_value0.'</td>';
print '<td>'.$value->job_uri->_value0.'</td>';
print '</tr>';
}
}
print "</table>";
}

View File

@ -39,7 +39,7 @@ class ExtraFields
var $attribute_type;
// Tableau contenant le nom des champs en clef et le label de ces champs en value
var $attribute_label;
// Tableau contenant le nom des champs en clef et la taille de ces champs en value
// Tableau contenant le nom des champs en clef et la taille/longueur max de ces champs en value
var $attribute_size;
// Tableau contenant le nom des choix en clef et la valeur de ces choix en value
var $attribute_choice;
@ -124,6 +124,7 @@ class ExtraFields
if (empty($label)) return -1;
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
// Create field into database except for separator type which is not stored in database
if ($type != 'separate')
@ -169,6 +170,7 @@ class ExtraFields
private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0)
{
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
$table=$elementtype.'_extrafields';
@ -248,6 +250,7 @@ class ExtraFields
global $conf;
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
// Clean parameters
if (empty($pos)) $pos=0;
@ -308,6 +311,7 @@ class ExtraFields
function delete($attrname, $elementtype='member')
{
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
$table=$elementtype.'_extrafields';
@ -342,6 +346,7 @@ class ExtraFields
global $conf;
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
@ -389,6 +394,7 @@ class ExtraFields
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='')
{
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
$table=$elementtype.'_extrafields';
@ -486,6 +492,8 @@ class ExtraFields
// Clean parameters
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
if (empty($list)) $list=0;
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
@ -570,6 +578,7 @@ class ExtraFields
if ( empty($elementtype) ) return array();
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
$array_name_label=array();

View File

@ -116,9 +116,9 @@ class HookManager
* @param array $parameters Array of parameters
* @param Object $object Object to use hooks on
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
* @return mixed For doActions,formObjectOptions,pdf_xxx: Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 means KO.
* For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Deprecated. Must always return an int and things to print into ->resprints.
* Can also return some values into an array ->results.
* @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO.
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint.
* All types can also return some values into an array ->results.
* $this->error or this->errors are also defined by class called by this function if error.
*/
function executeHooks($method, $parameters=false, &$object='', &$action='')
@ -135,7 +135,8 @@ class HookManager
array(
'addMoreActionsButtons',
'addStatisticLine',
'doActions',
'deleteFile',
'doActions',
'formCreateThirdpartyOptions',
'formObjectOptions',
'formattachOptions',
@ -147,7 +148,7 @@ class HookManager
'formatEvent'
)
)) $hooktype='addreplace';
// Deprecated hook types
// Deprecated hook types ('returnvalue')
if (preg_match('/^pdf_/',$method) && $method != 'pdf_writelinedesc') $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are 'returnvalue' hooks. When there is 2 hooks of this type, only last one win. TODO Move them into 'output' or 'addreplace' hooks.
if ($method == 'insertExtraFields')
{
@ -195,7 +196,7 @@ class HookManager
if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results);
if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints;
}
// Generic hooks that return a string or array (printSearchForm, printLeftBlock, formAddObjectLine, formBuilddocOptions, ...)
// Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...)
else
{
// TODO. this should be done into the method of hook by returning nothing

File diff suppressed because it is too large Load Diff

View File

@ -105,6 +105,10 @@ class FormAdmin
}
$out.= '</select>';
// Make select dynamic
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($htmlname);
return $out;
}

View File

@ -210,6 +210,7 @@ class FormCompany
* @param string $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show
* @param string $htmlname Id of department
* @return string String with HTML select
* @see select_country
*/
function select_state($selected='',$country_codeid=0, $htmlname='state_id')
{
@ -234,7 +235,7 @@ class FormCompany
$result=$this->db->query($sql);
if ($result)
{
if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat minwidth300" name="'.$htmlname.'">';
if ($country_codeid) $out.= '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($result);
$i = 0;
@ -277,13 +278,17 @@ class FormCompany
}
}
if (! empty($htmlname)) $out.= '</select>';
if (! empty($htmlname) && $user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
else
{
dol_print_error($this->db);
}
// Make select dynamic
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname);
return $out;
}
@ -418,6 +423,7 @@ class FormCompany
* @param string $filter Add a SQL filter on list
* @return void
* @deprecated Use print xxx->select_juridicalstatus instead
* @see select_juridicalstatus()
*/
function select_forme_juridique($selected='', $country_codeid=0, $filter='')
{
@ -431,9 +437,10 @@ class FormCompany
* @param string $selected Preselected code of juridical type
* @param int $country_codeid 0=list for all countries, otherwise list only country requested
* @param string $filter Add a SQL filter on list
* @param string $htmlname HTML name of select
* @return string String with HTML select
*/
function select_juridicalstatus($selected='', $country_codeid=0, $filter='')
function select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code')
{
global $conf,$langs,$user;
$langs->load("dict");
@ -454,7 +461,7 @@ class FormCompany
if ($resql)
{
$out.= '<div id="particulier2" class="visible">';
$out.= '<select class="flat" name="forme_juridique_code" id="legal_form">';
$out.= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($country_codeid) $out.= '<option value="0">&nbsp;</option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select.
$num = $this->db->num_rows($resql);
@ -488,7 +495,7 @@ class FormCompany
// Show break when we are in multi country mode
if (empty($country_codeid) && $val['country_code'])
{
$out.= '<option value="0">----- '.$val['country']." -----</option>\n";
$out.= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n";
$country=$val['country'];
}
}
@ -507,7 +514,12 @@ class FormCompany
}
}
$out.= '</select>';
if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
// Make select dynamic
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname);
$out.= '</div>';
}
else

View File

@ -249,7 +249,7 @@ class FormFile
* @param string $modelselected Model to preselect by default
* @param string $allowgenifempty Allow generation even if list of template ($genallowed) is empty (show however a warning)
* @param string $forcenomultilang Do not show language option (even if MAIN_MULTILANGS defined)
* @param int $iconPDF Obsolete, see getDocumentsLink
* @param int $iconPDF Deprecated, see getDocumentsLink
* @param int $maxfilenamelength Max length for filename shown
* @param string $noform Do not output html form tags
* @param string $param More param on http links
@ -261,6 +261,11 @@ class FormFile
*/
function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='')
{
// Deprecation warning
if (0 !== $iconPDF) {
dol_syslog(__METHOD__ . ": passing iconPDF parameter is deprecated", LOG_WARNING);
}
global $langs, $conf, $user, $hookmanager;
global $form, $bc;
@ -684,7 +689,7 @@ class FormFile
$out='';
$this->numoffiles=0;
$file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir).'.pdf','/'), '\.meta$|\.png$');
$file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$');
// For ajax treatment
$out.= '<div id="gen_pdf_'.$modulesubdir.'" class="linkobject hideobject">'.img_picto('', 'refresh').'</div>'."\n";
@ -713,7 +718,7 @@ class FormFile
$mime=dol_mimetype($relativepath,'',0);
if (preg_match('/text/',$mime)) $out.= ' target="_blank"';
$out.= '>';
$out.= img_pdf($file["name"],2);
$out.= img_mime($relativepath, $file["name"]);
$out.= '</a>'."\n";
$this->numoffiles++;

Some files were not shown because too many files have changed in this diff Show More