Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Raphaël Doursenaud 2012-03-23 11:16:24 +01:00
commit e490f378d0
792 changed files with 23800 additions and 15522 deletions

View File

@ -12,8 +12,7 @@ Composant Version License Compatible GPL Usage
----------------------------------------------------------------------------
PHP libraries:
AdoDb-Date 0.21 Modified BSD License Yes Date convertion (not into rpm package)
ArtiChow 1.07 Public Domain Yes Graphics
CKEditor 3.6.1 GPL or LGPL 2.1 or MPL 1.1 Yes Editor WYSIWYG
CKEditor 3.6.2 GPL or LGPL 2.1 or MPL 1.1 Yes Editor WYSIWYG
FPDI 1.4.1 Apache Software License 2.0 ? PDF templates management
GeoIP 2004 LGPL 2.1 Yes Sample code to make geoip convert (not into deb package)
NuSoap 0.9.5 LGPL 2.1 Yes Library to develop SOAP Web services (not into rpm and deb package)

View File

@ -8,6 +8,7 @@ WARNING: Because of a major datastructure change onto supplier prices tabkes, be
to make a backup of your database before making upgrade.
For users:
- New: Each user can remove/add its own boxes.
- New: Can use personalized fields of products/services.
- New: Can attach files on social contributions.
- New: Show payments terms and conditions onto muscadet template.
@ -52,6 +53,7 @@ For users:
- New: Default output charset are utf8 into backup tool.
- New: Add brazilian states.
- New: Increase usability of module project.
- New: [ task #285 ] Add search filter on project in tasks list.
- New: Automatic list of documents in ECM module is ok for customers,
suppliers invoice, orders, customers orders, proposals and social contributions.
- New: All professional id can contains up to 128 chars instead of 32.
@ -78,6 +80,7 @@ For developers:
- New: A page can force reload of css style sheet
- New: A module can add import description for import wizard, even for tables with foreign keys.
- New: Can add tabs on statistics views.
- New: Add CSS id/class into public payment pages.
- Qual: Add a lot of more PHPUnit tests.
- Qual: Data structure for supplier prices is simpler.
- Qual: Removed no more used external libraries.

View File

@ -2,7 +2,7 @@
<project name="dolibarr" default="hudson" basedir=".">
<!-- Exclude/ignore paths -->
<property name="ignorepaths" value="${basedir}/htdocs/core/filemanagerdol,${basedir}/htdocs/includes" />
<property name="ignorepaths" value="${basedir}/htdocs/conf,${basedir}/htdocs/core/filemanagerdol,${basedir}/htdocs/includes" />
<property name="ignoreregexp" value="**/PEAR/*,**/NET/*,**/HTTP/*" />
<target name="clean">
@ -43,6 +43,7 @@
<target name="phpcpd">
<exec executable="phpcpd">
<arg line=" --log-pmd '${basedir}/hudson/logs/pmd-cpd.xml'
--exclude '${basedir}/htdocs/conf'
--exclude '${basedir}/htdocs/core/filemanagerdol'
--exclude '${basedir}/htdocs/includes'
--exclude '**/PEAR/*,**/NET/*,**/HTTP/*'
@ -57,6 +58,7 @@
<target name="phploc">
<exec executable="phploc">
<arg line=" --log-csv '${basedir}/hudson/logs/phploc.csv'
--exclude '${basedir}/htdocs/conf'
--exclude '${basedir}/htdocs/core/filemanagerdol'
--exclude '${basedir}/htdocs/includes'
--exclude '**/PEAR/*,**/NET/*,**/HTTP/*'
@ -95,5 +97,5 @@
</exec>
</target>
<target name="hudson" depends="clean,parallelTasks,phpunit"/>
<target name="hudson" depends="clean,phpunit,parallelTasks"/>
</project>

View File

@ -1,4 +1 @@
# Embedded libraries, which don't seem to be available in Debian in correct version
# or because they were modified and are specific dolibarr code
#
# There is no embeded library in this package that are available into other Debian packages.
# No overrided lintian rules is this version.

View File

@ -83,15 +83,29 @@ case "$1" in
chown -R root:www-data $installconfig
chmod -R 660 $installconfig
# Create an empty conf.php with permission to web server
if [ ! -f $config ]
then
# Create an empty conf.php with permission to web server
echo Create empty file $config
touch $config
chown -R root:www-data $config
chmod -R 660 $config
chown -R root:www-data $config
else
# File already exist. We add params not found.
// Add new params to overwrite path to use shared libraries/fonts
grep -q -c "dolibarr_lib_ADODB_PATH" $config || echo "<?php \$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>" >> $config
grep -q -c "dolibarr_lib_FPDI_PATH" $config || echo "<?php \$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; ?>" >> $config
grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config
grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || echo "<?php \$dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>" >> $config
grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || echo "<?php \$dolibarr_lib_ODTPHP_PATHTOPCLZIP='/usr/share/php/libphp-pclzip'; ?>" >> $config
grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "<?php \$dolibarr_lib_PHPEXCEL_PATH=''; ?>" >> $config
grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "<?php \$dolibarr_lib_TCPDF_PATH=''; ?>" >> $config
grep -q -c "dolibarr_js_CKEDITOR" $config || echo "<?php \$dolibarr_js_CKEDITOR='/javascript/ckeditor'; ?>" >> $config
grep -q -c "dolibarr_js_JQUERY" $config || echo "<?php \$dolibarr_js_JQUERY='/javascript/jquery'; ?>" >> $config
grep -q -c "dolibarr_js_JQUERY_UI" $config || echo "<?php \$dolibarr_js_JQUERY_UI='/javascript/jquery-ui'; ?>" >> $config
grep -q -c "dolibarr_js_JQUERY_FLOT" $config || echo "<?php \$dolibarr_js_JQUERY_FLOT='/javascript/flot'; ?>" >> $config
grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "<?php \$dolibarr_font_DOL_DEFAULT_TTF_BOLD='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf'; ?>" >> $config
fi
db_get dolibarr/reconfigure-webserver

View File

@ -1,8 +1,8 @@
<?php
#
# Take a look at conf.php.example file for an example of conf.php file
# and explanations for all possibles parameters.
#
# This file will be filled by installer
#
//
// Take a look at conf.php.example file for an example of conf.php file
// and explanations for all possibles parameters.
//
// This file will be filled by installer
//
?>

View File

@ -89,7 +89,7 @@
</rule>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="9" />
<property name="nestingLevel" value="10" />
<property name="absoluteNestingLevel" value="50" />
</properties>
</rule>
@ -191,6 +191,9 @@
<rule ref="PEAR.Functions.ValidDefaultValue" />
<rule ref="PEAR.NamingConventions.ValidClassName" />
<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
<severity>0</severity>
</rule>
<rule ref="PEAR.NamingConventions.ValidClassName.StartWithCaptial">
<severity>0</severity>
</rule>

View File

@ -89,7 +89,7 @@
</rule>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="9" />
<property name="nestingLevel" value="10" />
<property name="absoluteNestingLevel" value="50" />
</properties>
</rule>
@ -191,6 +191,9 @@
<rule ref="PEAR.Functions.ValidDefaultValue" />
<rule ref="PEAR.NamingConventions.ValidClassName" />
<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
<severity>0</severity>
</rule>
<rule ref="PEAR.NamingConventions.ValidClassName.StartWithCaptial">
<severity>0</severity>
</rule>

View File

@ -87,10 +87,6 @@ class modMyModule extends DolibarrModules
// Data directories to create when module is enabled.
// Example: this->dirs = array("/mymodule/temp");
$this->dirs = array();
$r=0;
// Relative path to module style sheet if exists. Example: '/mymodule/css/mycss.css'.
//$this->style_sheet = '/mymodule/mymodule.css.php';
// Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
$this->config_page_url = array("mysetuppage.php@mymodule");

View File

@ -109,7 +109,6 @@ jQuery(document).ready(function() {
{
jQuery("#myid").removeAttr(\'disabled\');
jQuery("#myid").attr(\'disabled\',\'disabled\');
}
}
init_myfunc();
jQuery("#mybutton").click(function() {
@ -125,6 +124,6 @@ $somethingshown=$myobject->showLinkedObjectBlock();
// End of page
$db->close();
llxFooter();
$db->close();
?>

View File

@ -27,34 +27,34 @@
*/
class autoTranslator
{
private $translatedFiles = array();
private $destLang = '';
private $refLang = '';
private $langDir = '';
private $limittofile = '';
private $time;
private $time_end;
private $outputpagecode = 'UTF-8';
private $apikey;
//private $outputpagecode = 'ISO-8859-1';
private $_translatedFiles = array();
private $_destlang = '';
private $_refLang = '';
private $_langDir = '';
private $_limittofile = '';
private $_time;
private $_time_end;
private $_outputpagecode = 'UTF-8';
private $_apikey;
//private $_outputpagecode = 'ISO-8859-1';
const DIR_SEPARATOR = '/';
function __construct($destLang,$refLang,$langDir,$limittofile,$apikey)
function __construct($_destlang,$_refLang,$_langDir,$_limittofile,$_apikey)
{
// Set enviorment variables
$this->destLang = $destLang;
$this->refLang = $refLang;
$this->langDir = $langDir.self::DIR_SEPARATOR;
$this->time = date('Y-m-d H:i:s');
$this->limittofile = $limittofile;
$this->apikey = $apikey;
$this->_destlang = $_destlang;
$this->_refLang = $_refLang;
$this->_langDir = $_langDir.self::DIR_SEPARATOR;
$this->_time = date('Y-m-d H:i:s');
$this->_limittofile = $_limittofile;
$this->_apikey = $_apikey;
// Translate
//ini_set('default_charset','UTF-8');
ini_set('default_charset',$this->outputpagecode);
$this->parseRefLangTranslationFiles();
ini_set('default_charset',$this->_outputpagecode);
$this->parse_refLangTranslationFiles();
}
@ -63,31 +63,31 @@ class autoTranslator
*
* @return void
*/
private function parseRefLangTranslationFiles()
private function parse_refLangTranslationFiles()
{
$files = $this->getTranslationFilesArray($this->refLang);
$files = $this->getTranslationFilesArray($this->_refLang);
$counter = 1;
foreach($files as $file)
{
if ($this->limittofile && $this->limittofile != $file) continue;
if ($this->_limittofile && $this->_limittofile != $file) continue;
$counter++;
$fileContent = null;
$refPath = $this->langDir.$this->refLang.self::DIR_SEPARATOR.$file;
$refPath = $this->_langDir.$this->_refLang.self::DIR_SEPARATOR.$file;
$fileContent = file($refPath,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
print "Processing file " . $file . ", with ".count($fileContent)." lines<br>\n";
// Define target dirs
$targetlangs=array($this->destLang);
if ($this->destLang == 'all')
$targetlangs=array($this->_destlang);
if ($this->_destlang == 'all')
{
$targetlangs=array();
// If we must process all languages
$arraytmp=dol_dir_list($this->langDir,'directories',0);
$arraytmp=dol_dir_list($this->_langDir,'directories',0);
foreach($arraytmp as $dirtmp)
{
if ($dirtmp['name'] === $this->refLang) continue; // We discard source language
if ($dirtmp['name'] === $this->_refLang) continue; // We discard source language
$tmppart=explode('_',$dirtmp['name']);
if (preg_match('/^en/i',$dirtmp['name'])) continue; // We discard en_* languages
if (preg_match('/^fr/i',$dirtmp['name'])) continue; // We discard fr_* languages
@ -103,17 +103,17 @@ class autoTranslator
}
// Process translation of source file for each target languages
foreach($targetlangs as $mydestLang)
foreach($targetlangs as $my_destlang)
{
$this->translatedFiles = array();
$this->_translatedFiles = array();
$destPath = $this->langDir.$mydestLang.self::DIR_SEPARATOR.$file;
$destPath = $this->_langDir.$my_destlang.self::DIR_SEPARATOR.$file;
// Check destination file presence
if (! file_exists($destPath))
{
// No file present, we generate file
echo "File not found: " . $destPath . ". We generate it.<br>\n";
$this->createTranslationFile($destPath,$mydestLang);
$this->createTranslationFile($destPath,$my_destlang);
}
else
{
@ -128,11 +128,11 @@ class autoTranslator
$value = $this->getLineValue($line);
if ($key && $value)
{
$newlines+=$this->translateFileLine($fileContentDest,$file,$key,$value,$mydestLang);
$newlines+=$this->translateFileLine($fileContentDest,$file,$key,$value,$my_destlang);
}
}
$this->updateTranslationFile($destPath,$file,$mydestLang);
$this->updateTranslationFile($destPath,$file,$my_destlang);
echo "New translated lines: " . $newlines . "<br>\n";
//if ($counter ==3) die('fim');
}
@ -144,24 +144,24 @@ class autoTranslator
*
* @param string $destPath Target path
* @param string $file File
* @param string $mydestLang Target language code
* @param string $my_destlang Target language code
* @return void
*/
private function updateTranslationFile($destPath,$file,$mydestLang)
private function updateTranslationFile($destPath,$file,$my_destlang)
{
$this->time_end = date('Y-m-d H:i:s');
$this->_time_end = date('Y-m-d H:i:s');
if (count($this->translatedFiles[$file])>0)
if (count($this->_translatedFiles[$file])>0)
{
$fp = fopen($destPath, 'a');
fwrite($fp, "\r\n");
fwrite($fp, "\r\n");
fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->time.").\r\n");
fwrite($fp, "// Reference language: ".$this->refLang." -> ".$mydestLang."\r\n");
foreach( $this->translatedFiles[$file] as $line) {
fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->_time.").\r\n");
fwrite($fp, "// Reference language: ".$this->_refLang." -> ".$my_destlang."\r\n");
foreach( $this->_translatedFiles[$file] as $line) {
fwrite($fp, $line . "\r\n");
}
fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->time_end.").\r\n");
fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->_time_end.").\r\n");
fclose($fp);
}
return;
@ -171,32 +171,32 @@ class autoTranslator
* Create a new translation file
*
* @param string $path Path
* @param string $mydestlang Target language code
* @param string $my_destlang Target language code
* @return void
*/
private function createTranslationFile($path,$mydestlang)
private function createTranslationFile($path,$my_destlang)
{
$fp = fopen($path, 'w+');
fwrite($fp, "/*\r\n");
fwrite($fp, " * Language code: {$mydestlang}\r\n");
fwrite($fp, " * Language code: {$my_destlang}\r\n");
fwrite($fp, " * Automatic generated via autotranslator.php tool\r\n");
fwrite($fp, " * Generation date " . $this->time. "\r\n");
fwrite($fp, " * Generation date " . $this->_time. "\r\n");
fwrite($fp, " */\r\n");
fclose($fp);
return;
}
/**
* Put in array translatedFiles[$file], line of a new tranlated pair
* Put in array _translatedFiles[$file], line of a new tranlated pair
*
* @param string $content Existing content of dest file
* @param string $file Target file name translated (xxxx.lang)
* @param string $key Key to translate
* @param string $value Existing value in source file
* @param string $mydestLang Language code (ie: fr_FR)
* @param string $my_destlang Language code (ie: fr_FR)
* @return int 0=Nothing translated, 1=Record translated
*/
private function translateFileLine($content,$file,$key,$value,$mydestLang)
private function translateFileLine($content,$file,$key,$value,$my_destlang)
{
//print "key =".$key."\n";
@ -211,21 +211,21 @@ class autoTranslator
}
}
if ($key == 'CHARSET') $val=$this->outputpagecode;
if ($key == 'CHARSET') $val=$this->_outputpagecode;
else if (preg_match('/^Format/',$key)) $val=$value;
else if ($value=='-') $val=$value;
else
{
// If not translated then translate
if ($this->outputpagecode == 'UTF-8') $val=$this->translateTexts(array($value),substr($this->refLang,0,2),substr($mydestLang,0,2));
else $val=utf8_decode($this->translateTexts(array($value),substr($this->refLang,0,2),substr($mydestLang,0,2)));
if ($this->_outputpagecode == 'UTF-8') $val=$this->translateTexts(array($value),substr($this->_refLang,0,2),substr($my_destlang,0,2));
else $val=utf8_decode($this->translateTexts(array($value),substr($this->_refLang,0,2),substr($my_destlang,0,2)));
}
$val=trim($val);
if (empty($val)) return 0;
$this->translatedFiles[$file][] = $key . '=' . $val ;
$this->_translatedFiles[$file][] = $key . '=' . $val ;
return 1;
}
@ -261,7 +261,7 @@ class autoTranslator
*/
private function getTranslationFilesArray($lang)
{
$dir = new DirectoryIterator($this->langDir.$lang);
$dir = new DirectoryIterator($this->_langDir.$lang);
while($dir->valid()) {
if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./',$dir->getFilename())) {
$files[] = $dir->getFilename();
@ -297,8 +297,8 @@ class autoTranslator
//$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair);
// Example: http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Setup%20area&langpair=en_US|fr_FR
// Define GET URL v2
$url = "https://www.googleapis.com/language/translate/v2?key=".$this->apikey."&q=".urlencode($src_text_to_translate)."&source=".urlencode($src_lang)."&target=".urlencode($dest_lang);
// Example: https://www.googleapis.com/language/translate/v2?key=APIKEY&q=Setup%20area&source=en_US&target=fr_FR
$url = "https://www.googleapis.com/language/translate/v2?key=".$this->_apikey."&q=".urlencode($src_text_to_translate)."&source=".urlencode($src_lang)."&target=".urlencode($dest_lang);
// Example: https://www.googleapis.com/language/translate/v2?key=_apikey&q=Setup%20area&source=en_US&target=fr_FR
// Send request
//print "Url to translate: ".$url."\n";

View File

@ -55,7 +55,7 @@ print "***** ".$script_file." (".$version.") *****\n";
$dir=DOL_DOCUMENT_ROOT."/langs";
// Check parameters
if (! isset($argv[2])) {
if (! isset($argv[3])) {
print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n";
print "Example: ".$script_file." en_US pt_PT 123456\n";
print "Rem: lang_code to use can be found on http://www.google.com/language_tools\n";

View File

@ -972,7 +972,7 @@ if ($rowid)
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
$tmp='<input name="sendmail" type="checkbox"'.($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?' checked="checked"':'').'>';
$tmp='<input name="sendmail" type="checkbox"'.((isset($_POST["sendmail"])?$_POST["sendmail"]:$conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked="checked"':'').'>';
$helpcontent='';
$helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";

View File

@ -1741,7 +1741,6 @@ class Adherent extends CommonObject
/**
* Return full address of member
*
*
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @return string Full address string

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -24,6 +24,7 @@
require("../main.inc.php");
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/infobox.class.php");
include_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
$langs->load("admin");
@ -51,69 +52,110 @@ if ($action == 'addconst')
if ($action == 'add')
{
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " WHERE fk_user = 0";
$sql.= " AND box_id = ".$_POST["boxid"];
$sql.= " AND position = ".$_POST["pos"];
$error=0;
$resql = $db->query($sql);
dol_syslog("boxes.php::search if box active sql=".$sql);
if ($resql)
$db->begin();
// Initialize distinctfkuser with all already existing values of fk_user (user that use a personalized view of boxes for pos)
$distinctfkuser=array();
if (! $error)
{
$num = $db->num_rows($resql);
if ($num == 0)
$sql = "SELECT fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE param = 'MAIN_BOXES_".$db->escape(GETPOST("pos","alpha"))."' AND value = '1'";
$sql.= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
dol_syslog("boxes.php search fk_user to activate box for sql=".$sql);
if ($resql)
{
$db->begin();
// Si la boite n'est pas deja active, insert with box_order=''
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql.= "box_id";
$sql.= ", position";
$sql.= ", box_order";
$sql.= ", fk_user";
$sql.= ") values (";
$sql.= $_POST["boxid"];
$sql.= ", ".$_POST["pos"];
$sql.= ", ''";
$sql.= ", 0";
$sql.= ")";
dol_syslog("boxes.php activate box sql=".$sql);
$resql = $db->query($sql);
// Remove all personalized setup when a box is activated or disabled
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
dol_syslog("boxes.php delete user_param sql=".$sql);
$resql = $db->query($sql);
$db->commit();
$num = $db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj=$db->fetch_object($resql);
$distinctfkuser[$obj->fk_user]=$obj->fk_user;
$i++;
}
}
else
{
$errmesg=$db->lasterror();
$error++;
}
}
foreach($distinctfkuser as $fk_user)
{
if (! $error && $fk_user != 0) // We will add fk_user = 0 later.
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql.= "box_id, position, box_order, fk_user";
$sql.= ") values (";
$sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', ".$fk_user;
$sql.= ")";
dol_syslog("boxes.php activate box sql=".$sql);
$resql = $db->query($sql);
if (! $resql)
{
$errmesg=$db->lasterror();
$error++;
}
}
}
// If value 0 was not included, we add it.
if (! $error)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql.= "box_id, position, box_order, fk_user";
$sql.= ") values (";
$sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', 0";
$sql.= ")";
dol_syslog("boxes.php activate box sql=".$sql);
$resql = $db->query($sql);
if (! $resql)
{
$errmesg=$db->lasterror();
$error++;
}
}
if (! $error)
{
Header("Location: boxes.php");
$db->commit();
exit;
}
else
{
dol_print_error($db);
$db->rollback();
}
}
if ($action == 'delete')
{
$db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql = "SELECT box_id FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " WHERE rowid=".$rowid;
$resql = $db->query($sql);
$obj=$db->fetch_object($resql);
if (! empty($obj->box_id))
{
$db->begin();
// Remove all personalized setup when a box is activated or disabled
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
$resql = $db->query($sql);
// Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes)
// $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
// $sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
// $resql = $db->query($sql);
$db->commit();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " WHERE box_id=".$obj->box_id;
$resql = $db->query($sql);
$db->commit();
}
}
if ($action == 'switch')
@ -154,12 +196,19 @@ if ($action == 'switch')
* View
*/
$form=new Form($db);
$emptyuser=new User($db);
//$infobox=new InfoBox($db);
llxHeader('',$langs->trans("Boxes"));
print_fiche_titre($langs->trans("Boxes"),'','setup');
print $langs->trans("BoxesDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
dol_htmloutput_errors($errmesg);
/*
* Recherche des boites actives par defaut pour chaque position possible
* On stocke les boites actives par defaut dans $boxes[position][id_boite]=1
@ -195,20 +244,21 @@ if ($resql)
// This occurs just after an insert.
if ($decalage)
{
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$decalage." WHERE rowid=".$obj->rowid;
$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$decalage."' WHERE rowid=".$obj->rowid;
$db->query($sql);
}
}
if ($decalage)
{
// Si on a renumerote, on corrige champ box_order
// Si on a renumerote, on corrige champ box_order
// This occurs just after an insert.
$sql = "SELECT box_order";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " WHERE length(box_order) <= 2";
$result = $db->query($sql);
dol_syslog("Execute requests to renumber box order sql=".$sql);
$result = $db->query($sql);
if ($result)
{
while ($record = $db->fetch_array($result))
@ -218,13 +268,13 @@ if ($resql)
if (preg_match("/[13579]{1}/",substr($record['box_order'],-1)))
{
$box_order = "A0".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = ".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'";
$resql = $db->query($sql);
}
else if (preg_match("/[02468]{1}/",substr($record['box_order'],-1)))
{
$box_order = "B0".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = ".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'";
$resql = $db->query($sql);
}
}
@ -233,13 +283,13 @@ if ($resql)
if (preg_match("/[13579]{1}/",substr($record['box_order'],-1)))
{
$box_order = "A".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = ".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'";
$resql = $db->query($sql);
}
else if (preg_match("/[02468]{1}/",substr($record['box_order'],-1)))
{
$box_order = "B".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = ".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'";
$resql = $db->query($sql);
}
}
@ -251,6 +301,7 @@ if ($resql)
// Available boxes
$boxtoadd=InfoBox::listboxes($db,'available',-1,$emptyuser,$actives);
print "<br>\n";
print_titre($langs->trans("BoxesAvailable"));
@ -262,103 +313,45 @@ print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>';
print '<td>'.$langs->trans("SourceFile").'</td>';
print '<td width="160">'.$langs->trans("ActivateOn").'</td>';
print "</tr>\n";
$sql = "SELECT rowid, file, note, tms";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def";
$sql.= " WHERE entity = ".$conf->entity;
$resql = $db->query($sql);
$var=true;
if ($resql)
foreach($boxtoadd as $box)
{
$form=new Form($db);
$var=!$var;
$num = $db->num_rows($resql);
$i = 0;
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
{
$logo = $box->boximg;
}
else
{
$logo=preg_replace("/^object_/i","",$box->boximg);
}
// Boucle sur toutes les boites
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bc[$var].'>';
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
print '<td>' . ($box->note?$box->note:'&nbsp;') . '</td>';
print '<td>' . $box->sourcefile . '</td>';
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{
$boxname = $regs[1];
$module = $regs[2];
$sourcefile = "/".$module."/core/boxes/".$boxname.".php";
}
else
{
$boxname=preg_replace('/.php$/i','',$obj->file);
$sourcefile = "/core/boxes/".$boxname.".php";
}
// Pour chaque position possible, on affiche un lien d'activation si boite non deja active pour cette position
print '<td>';
print $form->selectarray("pos",$pos_name);
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="boxid" value="'.$box->box_id.'">';
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
print '</td>';
dol_include_once($sourcefile);
if (class_exists($boxname))
{
$box=new $boxname($db,$obj->note);
$enabled=true;
if ($box->depends && count($box->depends) > 0)
{
foreach($box->depends as $module)
{
if (empty($conf->$module->enabled)) $enabled=false;
}
}
if ($enabled)
{
//if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1)
if (in_array($obj->rowid, $actives))
{
// La boite est deja activee
}
else
{
$var=!$var;
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
{
$logo = $box->boximg;
}
else
{
$logo=preg_replace("/^object_/i","",$box->boximg);
}
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr '.$bc[$var].'>';
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
print '<td>' . ($obj->note?$obj->note:'&nbsp;') . '</td>';
print '<td>' . $sourcefile . '</td>';
// Pour chaque position possible, on affiche un lien
// d'activation si boite non deja active pour cette position
print '<td>';
print $form->selectarray("pos",$pos_name);
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="boxid" value="'.$obj->rowid.'">';
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
print '</td>';
print '</tr></form>';
}
}
}
$i++;
}
$db->free($resql);
print '</tr>';
print '</form>';
}
print '</table>';
// Activated boxes
$boxactivated=InfoBox::listboxes($db,'activated',-1,$emptyuser);
print "<br>\n\n";
print_titre($langs->trans("BoxesActivated"));
@ -372,89 +365,39 @@ print '<td align="center" width="60" colspan="2">'.$langs->trans("PositionByDefa
print '<td align="center" width="80">'.$langs->trans("Disable").'</td>';
print '</tr>'."\n";
$sql = "SELECT b.rowid, b.box_id, b.position,";
$sql.= " bd.file, bd.note, bd.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
$sql.= " WHERE b.box_id = bd.rowid";
$sql.= " AND bd.entity = ".$conf->entity;
$sql.= " AND b.fk_user=0";
$sql.= " ORDER by b.position, b.box_order"; // Note box_order return A01,A03...,B02,B04...
$resql = $db->query($sql);
if ($resql)
$var=true;
$box_order=1;
$foundrupture=1;
foreach($boxactivated as $key => $box)
{
$num = $db->num_rows($resql);
$i = 0;
$var=true;
$var = ! $var;
$box_order=1;
$foundrupture=1;
// On lit avec un coup d'avance
$obj = $db->fetch_object($resql);
while ($obj && $i < $num)
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
{
$var = ! $var;
$objnext = $db->fetch_object($resql);
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{
$boxname = $regs[1];
$module = $regs[2];
$sourcefile = "/".$module."/core/boxes/".$boxname.".php";
}
else
{
$boxname=preg_replace('/.php$/i','',$obj->file);
$sourcefile = "/core/boxes/".$boxname.".php";
}
dol_include_once($sourcefile);
if (class_exists($boxname))
{
$box=new $boxname($db,$obj->note);
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
{
$logo = $box->boximg;
}
else
{
$logo=preg_replace("/^object_/i","",$box->boximg);
}
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
print '<tr '.$bc[$var].'>';
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
print '<td>' . ($obj->note?$obj->note:'&nbsp;') . '</td>';
print '<td align="center">' . $pos_name[$obj->position] . '</td>';
$hasnext=true;
$hasprevious=true;
if ($foundrupture) { $hasprevious=false; $foundrupture=0; }
if (! $objnext || $obj->position != $objnext->position) { $hasnext=false; $foundrupture=1; }
print '<td align="center">'.$box_order.'</td>';
print '<td align="center">';
print ($hasnext?'<a href="boxes.php?action=switch&switchfrom='.$obj->rowid.'&switchto='.$objnext->rowid.'">'.img_down().'</a>&nbsp;':'');
print ($hasprevious?'<a href="boxes.php?action=switch&switchfrom='.$obj->rowid.'&switchto='.$objprevious->rowid.'">'.img_up().'</a>':'');
print '</td>';
print '<td align="center">';
print '<a href="boxes.php?rowid='.$obj->rowid.'&amp;action=delete">'.img_delete().'</a>';
print '</td>';
print '</tr>'."\n";
}
$i++;
$box_order++;
if (! $foundrupture) $objprevious = $obj;
else $box_order=1;
$obj=$objnext;
$logo = $box->boximg;
}
else
{
$logo=preg_replace("/^object_/i","",$box->boximg);
}
$db->free($resql);
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
print '<tr '.$bc[$var].'>';
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
print '<td>' . ($box->note?$box->note:'&nbsp;') . '</td>';
print '<td align="center">' . $pos_name[$box->position] . '</td>';
$hasnext=($key < (count($boxactivated)-1));
$hasprevious=($key != 0);
print '<td align="center">'.($key+1).'</td>';
print '<td align="center">';
print ($hasnext?'<a href="boxes.php?action=switch&switchfrom='.$box->rowid.'&switchto='.$boxactivated[$key+1]->rowid.'">'.img_down().'</a>&nbsp;':'');
print ($hasprevious?'<a href="boxes.php?action=switch&switchfrom='.$box->rowid.'&switchto='.$boxactivated[$key-1]->rowid.'">'.img_up().'</a>':'');
print '</td>';
print '<td align="center">';
print '<a href="boxes.php?rowid='.$box->rowid.'&amp;action=delete">'.img_delete().'</a>';
print '</td>';
print '</tr>'."\n";
}
print '</table><br>';
@ -490,7 +433,7 @@ print '</form>';
print '</table>';
$db->close();
llxFooter();
$db->close();
?>

View File

@ -1,8 +1,9 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.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
@ -269,8 +270,8 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
* Edition des parametres
*/
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
jQuery("#selectcountry_id").change(function() {
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
document.form_index.action.value="updateedit";
document.form_index.submit();
});
@ -317,7 +318,7 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCurrency").'</td><td>';
$form->select_currency($conf->global->MAIN_MONNAIE,"currency");
$form->select_currency($conf->currency,"currency");
print '</td></tr>'."\n";
$var=!$var;
@ -661,27 +662,14 @@ else
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("State").'</td><td>';
if ($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT)
{
$sql = "SELECT code_departement as code, nom as label from ".MAIN_DB_PREFIX."c_departements where rowid = '".$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT."'";
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
}
else
{
dol_print_error($db);
}
$state=$obj->label;
print $state;
}
if ($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT) print getState($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT);
else print '&nbsp;';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyCurrency").'</td><td>';
print currency_name($conf->global->MAIN_MONNAIE,1);
print ' ('.$conf->global->MAIN_MONNAIE.')';
print currency_name($conf->currency,1);
print ' ('.getCurrencySymbol($conf->currency).')';
print '</td></tr>';
$var=!$var;
@ -980,8 +968,7 @@ else
print '<br>';
}
$db->close();
llxFooter();
?>

View File

@ -39,7 +39,7 @@ $langs->load("companies");
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
$confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int');
$rowid=GETPOST('rowid','int');
$rowid=GETPOST('rowid','alpha');
if (!$user->admin) accessforbidden();
@ -128,8 +128,7 @@ $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.civilite AS libelle, c.
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.deductible, p.code as pays_code, p.libelle as pays, a.fk_pays as pays_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1";
$tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent";
//$tabsql[9] = "SELECT code, code_iso, label as libelle, symbole, active FROM ".MAIN_DB_PREFIX."c_currencies";
$tabsql[9] = "SELECT code, code_iso, label as libelle, active FROM ".MAIN_DB_PREFIX."c_currencies";
$tabsql[9] = "SELECT code_iso as code, label as libelle, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies";
$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid";
$tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
$tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
@ -153,7 +152,7 @@ $tabsqlsort[5] ="libelle ASC";
$tabsqlsort[6] ="a.type ASC, a.module, a.position, a.code ASC";
$tabsqlsort[7] ="pays ASC, code ASC, a.libelle ASC";
$tabsqlsort[8] ="libelle ASC";
$tabsqlsort[9] ="code ASC";
$tabsqlsort[9] ="libelle ASC";
$tabsqlsort[10]="pays ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC";
$tabsqlsort[11]="element ASC, source ASC, code ASC";
$tabsqlsort[12]="sortorder ASC, code ASC";
@ -177,8 +176,7 @@ $tabfield[5] = "code,libelle";
$tabfield[6] = "code,libelle,type,position";
$tabfield[7] = "code,libelle,pays_id,pays,deductible";
$tabfield[8] = "code,libelle";
//$tabfield[9] = "code,code_iso,libelle,symbole";
$tabfield[9] = "code,code_iso,libelle";
$tabfield[9] = "code,libelle,unicode";
$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note";
$tabfield[11]= "element,source,code,libelle";
$tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
@ -202,8 +200,7 @@ $tabfieldvalue[5] = "code,libelle";
$tabfieldvalue[6] = "code,libelle,type,position";
$tabfieldvalue[7] = "code,libelle,pays,deductible";
$tabfieldvalue[8] = "code,libelle";
//$tabfieldvalue[9] = "code,code_iso,libelle,symbole";
$tabfieldvalue[9] = "code,code_iso,libelle";
$tabfieldvalue[9] = "code,libelle,unicode";
$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note";
$tabfieldvalue[11]= "element,source,code,libelle";
$tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
@ -227,8 +224,7 @@ $tabfieldinsert[5] = "code,civilite";
$tabfieldinsert[6] = "code,libelle,type,position";
$tabfieldinsert[7] = "code,libelle,fk_pays,deductible";
$tabfieldinsert[8] = "code,libelle";
//$tabfieldinsert[9] = "code,code_iso,label,symbole";
$tabfieldinsert[9] = "code,code_iso,label";
$tabfieldinsert[9] = "code_iso,label,unicode";
$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note";
$tabfieldinsert[11]= "element,source,code,libelle";
$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
@ -254,7 +250,7 @@ $tabrowid[5] = "rowid";
$tabrowid[6] = "id";
$tabrowid[7] = "id";
$tabrowid[8] = "id";
$tabrowid[9] = "code";
$tabrowid[9] = "code_iso";
$tabrowid[10]= "";
$tabrowid[11]= "rowid";
$tabrowid[12]= "rowid";
@ -281,8 +277,8 @@ $tabcond[8] = $conf->societe->enabled;
$tabcond[9] = true;
$tabcond[10]= true;
$tabcond[11]= true;
$tabcond[12]= $conf->commande->enabled||$conf->propale->enabled||$conf->facture->enabled||$conf->fournisseur->enabled;
$tabcond[13]= $conf->commande->enabled||$conf->propale->enabled||$conf->facture->enabled||$conf->fournisseur->enabled;
$tabcond[12]= $conf->commande->enabled||$conf->propal->enabled||$conf->facture->enabled||$conf->fournisseur->enabled;
$tabcond[13]= $conf->commande->enabled||$conf->propal->enabled||$conf->facture->enabled||$conf->fournisseur->enabled;
$tabcond[14]= $conf->product->enabled&&$conf->ecotax->enabled;
$tabcond[15]= true;
$tabcond[16]= $conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS);
@ -290,8 +286,8 @@ $tabcond[17]= $conf->deplacement->enabled;
$tabcond[18]= $conf->expedition->enabled;
$tabcond[19]= $conf->societe->enabled;
$tabcond[20]= $conf->fournisseur->enabled;
$tabcond[21]= $conf->propale->enabled;
$tabcond[22]= $conf->commande->enabled||$conf->propale->enabled;
$tabcond[21]= $conf->propal->enabled;
$tabcond[22]= $conf->commande->enabled||$conf->propal->enabled;
complete_dictionnary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond);
@ -645,24 +641,24 @@ if ($id)
if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
if ($fieldlist[$field]=='pays') {
if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input
$valuetoshow=$langs->trans("Country"); }
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; }
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); }
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); }
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); }
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $valuetoshow=''; }
if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
if ($valuetoshow != '')
{
print '<td>';
print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
$valuetoshow=$langs->trans("Country");
}
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; }
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); }
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); }
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); }
if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); }
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $valuetoshow=''; }
if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
if ($valuetoshow != '')
{
print '<td>';
print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
}
print '<td colspan="3">';
print '<input type="hidden" name="id" value="'.$id.'">';
@ -883,6 +879,9 @@ if ($id)
else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') {
$showfield=0;
}
else if ($fieldlist[$field]=='unicode') {
$valuetoshow = getCurrencySymbol($obj->code);
}
if ($showfield) print '<td>'.$valuetoshow.'</td>';
}
}

View File

@ -205,13 +205,13 @@ print '</tr>';
print '<tr class="impair">';
print '<td width="100">'.$langs->trans("Title").'</td>';
print '<td><input type="text" name="external_rss_title_'.($lastexternalrss+1).'" value="'.@constant("EXTERNAL_RSS_TITLE_" . ($lastexternalrss+1)).'" size="64"></td>';
print '<td>April,<br>LinuxFR,<br>Lolix</td>';
print '<td>An interesting RSS feed</td>';
print '</tr>';
print '<tr class="pair">';
print '<td>URL du RSS</td>';
print '<td><input type="text" name="external_rss_urlrss_'.($lastexternalrss+1).'" value="'.@constant("EXTERNAL_RSS_URLRSS_" . ($lastexternalrss+1)).'" size="64"></td>';
print '<td>http://news.google.com/news?ned=us&topic=h&output=rss<br>http://linuxfr.org/backend/news/rss20.rss</td>';
print '<td>http://news.google.com/news?ned=us&topic=h&output=rss<br>http://www.dolibarr.org/rss</td>';
print '</tr>';
print '</table>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 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
@ -26,8 +26,7 @@ require("../main.inc.php");
$langs->load("admin");
$langs->load("companies");
if (!$user->admin)
accessforbidden();
if (!$user->admin) accessforbidden();
$mesg='';
@ -65,7 +64,7 @@ print img_picto('','puce').' '.$langs->trans("SetupDescription4")."<br>";
print "<br>";
print '<br>';
//print '<hr style="color: #DDDDDD;">';
print img_picto('','puce').' '.$langs->trans("SetupDescription5")."<br>";
print $langs->trans("SetupDescription5")."<br>";
//print '<hr style="color: #DDDDDD;">';
print "<br>";

View File

@ -1,25 +1,25 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@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
* the Free Software Foundation; either version 2 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/>.
*/
* Copyright (C) 2010 Juanjo Menent <jmenent@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
* the Free Software Foundation; either version 2 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/>.
*/
/**
* \file htdocs/admin/limits.php
* \brief Page de configuration des limites
* \brief Page to setup limits
*/
require("../main.inc.php");

View File

@ -39,7 +39,9 @@ $substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord',
'__EMAIL__' => 'TESTEMail',
'__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname'
'__FIRSTNAME__' => 'TESTFirstname',
'__SIGNATURE__' => 'TESTSignature',
'__PERSONALIZED__' => 'TESTPersonalized'
);
complete_substitutions_array($substitutionarrayfortest, $langs);
@ -695,7 +697,7 @@ else
$formmail->param["returnurl"]=$_SERVER["PHP_SELF"];
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
if (GETPOST("mode")=='init')
{
$formmail->clear_attached_files();
}
@ -741,7 +743,7 @@ else
$formmail->param["returnurl"]=$_SERVER["PHP_SELF"];
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
if (GETPOST("mode")=='init')
{
$formmail->clear_attached_files();
}

View File

@ -105,6 +105,7 @@ $categ = array();
$dirmod = array();
$i = 0; // is a sequencer of modules found
$j = 0; // j is module number. Automatically affected if module number not defined.
$modNameLoaded=array();
foreach ($modulesdir as $dir)
{
@ -123,10 +124,18 @@ foreach ($modulesdir as $dir)
if ($modName)
{
if (! empty($modNameLoaded[$modName]))
{
$mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
dol_syslog($mesg, LOG_ERR);
continue;
}
try
{
$res=include_once($dir.$file);
$objMod = new $modName($db);
$modNameLoaded[$modName]=$dir;
if ($objMod->numero > 0)
{
@ -457,7 +466,7 @@ else
$var=!$var;
print "<tr ".$bc[$var].">\n";
$url='http://www.dolistore.com';
print '<td align="left"><a href="'.$url.'" target="_blank"><img border="0" src="'.DOL_URL_ROOT.'/theme/common/dolistore.jpg"></a></td>';
print '<td align="left"><a href="'.$url.'" target="_blank"><img border="0" width="180" src="'.DOL_URL_ROOT.'/theme/dolistore_logo.png"></a></td>';
print '<td>'.$langs->trans("DoliStoreDesc").'</td>';
print '<td><a href="'.$url.'" target="_blank">'.$url.'</a></td>';
print '</tr>';

View File

@ -338,14 +338,14 @@ foreach ($dirmodels as $reldir)
}
print '</td>';
$propale=new Propal($db);
$propale->initAsSpecimen();
$propal=new Propal($db);
$propal->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc,$propale);
$nextval=$module->getNextValue($mysoc,$propal);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
@ -631,7 +631,7 @@ print "<tr class=\"liste_titre\">\n";
print " <td>".$langs->trans("Name")."</td>\n";
print " <td>".$langs->trans("Value")."</td>\n";
print "</tr>\n";
print "<tr ".$bc[false].">\n <td width=\"140\">".$langs->trans("PathDirectory")."</td>\n <td>".$conf->propale->dir_output."</td>\n</tr>\n";
print "<tr ".$bc[false].">\n <td width=\"140\">".$langs->trans("PathDirectory")."</td>\n <td>".$conf->propal->dir_output."</td>\n</tr>\n";
print "</table>\n<br>";
dol_htmloutput_mesg($mesg);

View File

@ -143,12 +143,6 @@ $linuxlike=1;
if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
/*
* View
*/
$wikihelp='EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms';
llxHeader('',$langs->trans("Setup"),$wikihelp);
@ -349,7 +343,7 @@ else
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -28,6 +28,7 @@ require("../../main.inc.php");
$langs->load("admin");
$langs->load("help");
$langs->load("members");
/*
@ -39,16 +40,11 @@ llxHeader();
print_fiche_titre("Dolibarr",'','setup');
print $langs->trans("Version").':';
print '<ul>';
print '<li>'.DOL_VERSION.'</li>';
print '</ul>';
print '<div style="padding-left: 30px;">'.img_picto_common('', 'dolibarr_box.png','height="120"').'</div>';
print "<br>\n";
print $langs->trans("DolibarrLicense").':';
print $langs->trans("Version").' / '.$langs->trans("DolibarrLicense").':';
print '<ul>';
print '<li>GNU/GPL</li>';
print '<li>'.DOL_VERSION.' / <a href="http://www.gnu.org/copyleft/gpl.html">GNU-GPL</a></li>';
print '</ul>';
print "<br>\n";
@ -56,6 +52,7 @@ print "<br>\n";
print $langs->trans("Developpers").':';
print '<ul>';
print '<li>'.$langs->trans("SeeWikiForAllTeam").': <a href="http://wiki.dolibarr.org/index.php/Dolibarr_Project" target="_blank">http://wiki.dolibarr.org/index.php/Dolibarr_Project</a></li>';
print '<li>'.$langs->trans("DoliForge").': <a href="http://www.doliforge.org" target="_blank">http://wwww.doliforge.org</a></li>';
print '</ul>';
print "<br>\n";
@ -76,28 +73,20 @@ if (preg_match('/^fr_/i',$langs->getDefaultLang()))
print '<li>';
print '<a target="blank" href="http://wiki.dolibarr.org/">'.$langs->trans("OfficialWiki").'</a>';
print '</li>';
print '</ul>';
print $langs->trans("Demo").':';
print '<ul>';
print '<li>';
print '<a target="blank" href="http://demo.dolibarr.org/public/demo">'.$langs->trans("OfficialDemo").'</a>';
print '<a target="blank" href="http://www.dolibarr.org/onlinedemo/">'.$langs->trans("OfficialDemo").'</a>';
print '</li>';
print '</ul>';
print $langs->trans("ModulesMarketPlaces").':';
print '<ul>';
print '<li>';
print '<a target="blank" href="http://www.dolistore.com">'.$langs->trans("OfficialMarketPlace").'</a>';
print '</li>';
if (preg_match('/^fr_/i',$langs->getDefaultLang()))
{
print '<li>';
print 'Les t&acirc;ches en cours de r&eacute;alisation sur Dolibarr sont consultables dans le <a target="blank" href="http://savannah.nongnu.org/task/?group=dolibarr">gestionnaire de projets</a> sur Savannah.';
print '</li>';
print '<li>';
print 'Si vous trouvez un bogue dans Dolibarr, vous pouvez en informer les d&eacute;veloppeurs sur le <a target="blank" href="http://savannah.nongnu.org/bugs/?group=dolibarr">syst&egrave;me de gestion des bogues</a> de Savannah.';
print '</li>';
print '<li>';
print 'Le code source de Dolibarr est consultable par l\'<a target="_blank" href="http://savannah.nongnu.org/cgi-bin/viewcvs/dolibarr/dolibarr/">interface web du cvs</a>.';
print '</li>';
}
print '</ul>';
@ -109,19 +98,18 @@ print '<a target="_blank" href="'.DOL_URL_ROOT.'/support/index.php">'.$langs->tr
print '</li>';
print '</ul>';
print '<br>'.$langs->trans("MakeADonation").':<br>';
print $langs->trans("Foundation").':<br>';
print '<ul>';
print '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="6573525">';
print '<input class="none" type="image" src="'.DOL_URL_ROOT.'/theme/common/paypal.png" border="0" name="submit" alt="Help Dolibarr making a donation">';
print '</form>';
$url='http://wiki.dolibarr.org/index.php/Subscribe';
if (preg_match('/^fr_/i',$langs->getDefaultLang())) $url='http://wiki.dolibarr.org/index.php/Adh%C3%A9rer';
print '<li><a href="'.$url.'">'.$langs->trans("SubscribeToFoundation").'</a></li>';
print '</ul>';
llxFooter();
$db->close();
?>

View File

@ -44,7 +44,7 @@ print_fiche_titre($langs->trans("DatabaseConfiguration"),'','setup');
// Database
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("Version").'</td><td>'.$db->getLabel().' '.$db->getVersion().'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("Version").'</td><td>'.getStaticMember(get_class($db),'label').' '.$db->getVersion().'</td></tr>'."\n";
print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n";
print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DatabasePort").'</td><td>'.(empty($conf->db->port)?$langs->trans("Default"):$conf->db->port).'</td></tr>'."\n";
print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n";

View File

@ -86,7 +86,7 @@ print "<br>\n";
// Database
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Database")."</td></tr>\n";
$dblabel=$db->getLabel();
$dblabel=getStaticMember(get_class($db),'label');
$dbversion=$db->getVersion();
print "<tr $bc[0]><td width=\"280\">".$langs->trans("Version")."</td><td>" .$dblabel." ".$dbversion."</td></tr>\n";
print '</table>';

View File

@ -61,6 +61,8 @@ if ($action == 'delete')
$form=new Form($db);
$formfile = new FormFile($db);
$label=getStaticMember($db, 'label');
$help_url='EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
llxHeader('','',$help_url);
@ -75,7 +77,6 @@ jQuery(document).ready(function() {
}
hideoptions();
jQuery("#radio_dump_mysql").click(function() {
hideoptions();
jQuery("#mysql_options").show();
@ -94,6 +95,11 @@ jQuery(document).ready(function() {
jQuery("#checkbox_dump_disable-add-locks").attr('checked',true);
};
});
<?php
if ($label == 'MySQL') print 'jQuery("#radio_dump_mysql").click();';
if ($label == 'PostgreSQL') print 'jQuery("#radio_dump_postgresql").click();';
?>
});
</script>
<?php
@ -114,8 +120,6 @@ if ($_GET["msg"])
}
$label=getStaticMember($db, 'label');
?>
<!-- Dump of a server -->

View File

@ -33,6 +33,8 @@ if (! $user->admin) accessforbidden();
* View
*/
$label=getStaticMember($db, 'label');
$help_url='EN:Restores|FR:Restaurations|ES:Restauraciones';
llxHeader('','',$help_url);
@ -48,6 +50,10 @@ jQuery(document).ready(function() {
jQuery("#radio_dump_postgresql").click(function() {
jQuery("#postgresql_options").show();
});
<?php
if ($label == 'MySQL') print 'jQuery("#radio_dump_mysql").click();';
if ($label == 'PostgreSQL') print 'jQuery("#radio_dump_postgresql").click();';
?>
});
</script>
<?php
@ -58,8 +64,6 @@ print $langs->trans("RestoreDesc",DOL_DATA_ROOT).'<br><br>';
print $langs->trans("RestoreDesc2",DOL_DATA_ROOT).'<br><br>';
print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'<br><br>';
$label=getStaticMember($db, 'label');
?>
<fieldset id="fieldsetexport">
@ -166,7 +170,7 @@ else if ($label == 'PostgreSQL')
print '<br>';
print '<textarea rows="1" cols="120">'.$langs->trans("ImportPostgreSqlCommand",$command,$_GET["showpass"]?$paramclear:$paramcrypted).'</textarea><br>';
if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=1&amp;radio_dump=postgresql_options">'.$langs->trans("UnHidePassword").'</a>';
//if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=1&amp;radio_dump=postgresql_options">'.$langs->trans("UnHidePassword").'</a>';
//else print '<br><a href="'.$_SERVER["PHP_SELF"].'?showpass=0&amp;radio_dump=mysql_options">'.$langs->trans("HidePassword").'</a>';
?>
</div>

72
htdocs/admin/translation.php Executable file
View File

@ -0,0 +1,72 @@
<?php
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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/>.
*/
/**
* \file htdocs/admin/translation.php
* \brief Page to show translation information
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
$langs->load("companies");
$langs->load("products");
$langs->load("admin");
$langs->load("sms");
$langs->load("other");
$langs->load("errors");
if (!$user->admin) accessforbidden();
$action=GETPOST('action');
/*
* Actions
*/
// None
/*
* View
*/
$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración';
llxHeader('',$langs->trans("Setup"),$wikihelp);
print_fiche_titre($langs->trans("TranslationSetup"),'','setup');
print $langs->trans("TranslationDesc")."<br>\n";
print "<br>\n";
dol_htmloutput_mesg($message);
print $langs->trans("CurrentUserLanguage").': <strong>'.$langs->defaultlang.'</strong><br>';
print img_warning().' '.$langs->trans("SomeTranslationAreUncomplete").'<br>';
$urlwikitranslatordoc='http://wiki.dolibarr.org/index.php/Translator_documentation';
print $langs->trans("SeeAlso").': <a href="'.$urlwikitranslatordoc.'" target="_blank">'.$urlwikitranslatordoc.'</a><br>';
llxFooter();
$db->close();
?>

View File

@ -1,429 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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/>.
*/
/**
* \file htdocs/boxes.php
* \brief File of class to manage widget boxes
* \author Rodolphe Qiedeville
* \author Laurent Destailleur
*/
/**
* Show a HTML Tab with boxes of a particular area including personalized choices of user
*
* @param User $user Object User
* @param String $areacode Code of area for pages (0=value for Home page)
* @return int <0 if KO, Nb of boxes shown of OK (0 to n)
*/
function printBoxesArea($user,$areacode)
{
global $conf,$langs,$db;
$infobox=new InfoBox($db);
$boxarray=$infobox->listboxes($areacode,$user);
if (count($boxarray))
{
print load_fiche_titre($langs->trans("OtherInformationsBoxes"),'','','','otherboxes');
print '<table width="100%" class="notopnoleftnoright">';
print '<tr><td class="notopnoleftnoright">'."\n";
print '<div class="fichehalfleft">';
print "\n<!-- Box left container -->\n";
print '<div id="left" class="connectedSortable">'."\n";
// Define $box_max_lines
$box_max_lines=5;
if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES;
$ii=0;
foreach ($boxarray as $key => $box)
{
if (preg_match('/^A/i',$box->box_order)) // column A
{
$ii++;
//print 'box_id '.$boxarray[$ii]->box_id.' ';
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
// Affichage boite key
$box->loadBox($box_max_lines);
$box->showBox();
}
}
$emptybox=new ModeleBoxes($db);
$emptybox->box_id='A';
$emptybox->info_box_head=array();
$emptybox->info_box_contents=array();
$emptybox->showBox(array(),array());
print "</div>\n";
print "<!-- End box container -->\n";
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
print "\n<!-- Box right container -->\n";
print '<div id="right" class="connectedSortable">'."\n";
$ii=0;
foreach ($boxarray as $key => $box)
{
if (preg_match('/^B/i',$box->box_order)) // colonne B
{
$ii++;
//print 'box_id '.$boxarray[$ii]->box_id.' ';
//print 'box_order '.$boxarray[$ii]->box_order.'<br>';
// Affichage boite key
$box->loadBox($box_max_lines);
$box->showBox();
}
}
$emptybox=new ModeleBoxes($db);
$emptybox->box_id='B';
$emptybox->info_box_head=array();
$emptybox->info_box_contents=array();
$emptybox->showBox(array(),array());
print "</div>\n";
print "<!-- End box container -->\n";
print '</div></div>';
print "\n";
print "</td></tr>";
print "</table>";
if ($conf->use_javascript_ajax)
{
print "\n";
print '<script type="text/javascript" language="javascript">';
print 'jQuery(function() {
jQuery("#left, #right").sortable({
/* placeholder: \'ui-state-highlight\', */
handle: \'.boxhandle\',
revert: \'invalid\',
items: \'.box\',
containment: \'.fiche\',
connectWith: \'.connectedSortable\',
stop: function(event, ui) {
updateOrder();
}
});
});
';
print "\n";
print 'function updateOrder(){'."\n";
print 'var left_list = cleanSerialize(jQuery("#left").sortable("serialize" ));'."\n";
print 'var right_list = cleanSerialize(jQuery("#right").sortable("serialize" ));'."\n";
print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;'."\n";
//print 'alert(\'boxorder=\' + boxorder);';
print 'var userid = \''.$user->id.'\';'."\n";
print 'jQuery.get(\'core/ajax/box.php?boxorder=\'+boxorder+\'&userid=\'+'.$user->id.');'."\n";
print '}'."\n";
print '</script>'."\n";
}
}
return count($boxarray);
}
/**
* Class to manage boxes on pages
*/
class InfoBox
{
var $db;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
function InfoBox($db)
{
$this->db=$db;
}
/**
* Return array of boxes qualified for area and user
*
* @param string $zone Name or area (0 for Homepage, ...)
* @param User $user Objet user
* @return array Array of boxes
*/
function listBoxes($zone,$user)
{
global $conf;
$boxes=array();
$confuserzone='MAIN_BOXES_'.$zone;
if ($user->id && $user->conf->$confuserzone)
{
// Get list of boxes of a particular user (if this one has its own list)
$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user,";
$sql.= " d.file, d.note";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
$sql.= " WHERE b.box_id = d.rowid";
$sql.= " AND d.entity = ".$conf->entity;
$sql.= " AND b.position = ".$zone;
$sql.= " AND b.fk_user = ".$user->id;
$sql.= " ORDER BY b.box_order";
dol_syslog("InfoBox::listBoxes get user box list sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
$j = 0;
while ($j < $num)
{
$obj = $this->db->fetch_object($result);
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{
$boxname = $regs[1];
$module = $regs[2];
$sourcefile = dol_buildpath("/".$module."/core/boxes/".$boxname.".php");
}
else
{
$boxname=preg_replace('/\.php$/i','',$obj->file);
$sourcefile = "/core/boxes/".$boxname.".php";
}
dol_include_once($sourcefile); // Do not use dol_include_once here because sourcefile is already good fullpath
if (class_exists($boxname))
{
$box=new $boxname($this->db,$obj->note);
$box->rowid=$obj->rowid;
$box->box_id=$obj->box_id;
$box->position=$obj->position;
$box->box_order=$obj->box_order;
$box->fk_user=$obj->fk_user;
$enabled=true;
if ($box->depends && count($box->depends) > 0)
{
foreach($box->depends as $module)
{
//print $module.'<br>';
if (empty($conf->$module->enabled)) $enabled=false;
}
}
if ($enabled) $boxes[]=$box;
}
$j++;
}
}
else
{
$this->error=$this->db->error();
dol_syslog("InfoBox::listBoxes Error ".$this->error, LOG_ERR);
return array();
}
}
else
{
// Recupere liste des boites active par defaut pour tous
$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user,";
$sql.= " d.file, d.note";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
$sql.= " WHERE b.box_id = d.rowid";
$sql.= " AND d.entity = ".$conf->entity;
$sql.= " AND b.position = ".$zone;
$sql.= " AND b.fk_user = 0";
$sql.= " ORDER BY b.box_order";
dol_syslog("InfoBox::listBoxes get default box list sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
$j = 0;
while ($j < $num)
{
$obj = $this->db->fetch_object($result);
if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs))
{
$boxname = $regs[1];
$module = $regs[2];
$relsourcefile = "/".$module."/core/boxes/".$boxname.".php";
}
else
{
$boxname=preg_replace('/.php$/i','',$obj->file);
$relsourcefile = "/core/boxes/".$boxname.".php";
}
dol_include_once($relsourcefile);
if (class_exists($boxname))
{
$box=new $boxname($this->db,$obj->note);
$box->rowid=$obj->rowid;
$box->box_id=$obj->box_id;
$box->position=$obj->position;
$box->box_order=$obj->box_order;
if (is_numeric($box->box_order))
{
if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order;
elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order;
}
$box->fk_user=$obj->fk_user;
$enabled=true;
if ($box->depends && count($box->depends) > 0)
{
foreach($box->depends as $module)
{
//print $boxname.'-'.$module.'<br>';
if (empty($conf->$module->enabled)) $enabled=false;
}
}
if ($enabled) $boxes[]=$box;
}
$j++;
}
}
else
{
$this->error=$this->db->error();
dol_syslog("InfoBox::listBoxes Error ".$this->error, LOG_ERR);
return array();
}
}
return $boxes;
}
/**
* Save order of boxes for area and user
*
* @param string $zone Name of area (0 for Homepage, ...)
* @param string $boxorder List of boxes with correct order 'A:123,456,...-B:789,321...'
* @param int $userid Id of user
* @return int <0 if KO, >= 0 if OK
*/
function saveboxorder($zone,$boxorder,$userid=0)
{
global $conf;
$error=0;
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
dol_syslog("InfoBoxes::saveboxorder zone=".$zone." user=".$userid);
if (! $userid || $userid == 0) return 0;
$user = new User($this->db);
$user->id=$userid;
$this->db->begin();
// Sauve parametre indiquant que le user a une
$confuserzone='MAIN_BOXES_'.$zone;
$tab[$confuserzone]=1;
if (dol_set_user_param($this->db, $conf, $user, $tab) < 0)
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -3;
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";
$sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";
$sql.= " AND ".MAIN_DB_PREFIX."boxes_def.entity = ".$conf->entity;
$sql.= " AND ".MAIN_DB_PREFIX."boxes.fk_user = ".$userid;
$sql.= " AND ".MAIN_DB_PREFIX."boxes.position = ".$zone;
dol_syslog("InfoBox::saveboxorder sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$colonnes=explode('-',$boxorder);
foreach ($colonnes as $collist)
{
$part=explode(':',$collist);
$colonne=$part[0];
$list=$part[1];
dol_syslog('InfoBox::saveboxorder column='.$colonne.' list='.$list);
$i=0;
$listarray=explode(',',$list);
foreach ($listarray as $id)
{
if (is_numeric($id))
{
//dol_syslog("aaaaa".count($listarray));
$i++;
$ii=sprintf('%02d',$i);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes";
$sql.= "(box_id, position, box_order, fk_user)";
$sql.= " values (";
$sql.= " ".$id.",";
$sql.= " ".$zone.",";
$sql.= " '".$colonne.$ii."',";
$sql.= " ".$userid;
$sql.= ")";
dol_syslog("InfoBox::saveboxorder sql=".$sql);
$result = $this->db->query($sql);
if ($result < 0)
{
$error++;
break;
}
}
}
}
if ($error)
{
$this->error=$this->db->error();
$this->db->rollback();
return -2;
}
else
{
$this->db->commit();
return 1;
}
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
dol_syslog("InfoBox::saveboxorder ".$this->error);
return -1;
}
}
}
?>

View File

@ -75,7 +75,7 @@ class Facturation
public function Facturation()
{
$this->raz();
$this->raz_pers();
$this->razPers();
}
@ -115,7 +115,7 @@ class Facturation
// Define part of HT, VAT, TTC
$resultarray=calcul_price_total($this->qte,$this->prix(),$this->remise_percent(),$vat_rate,0,0,0,'HT',0);
$resultarray=calcul_price_total($this->qte,$this->prix(),$this->remisePercent(),$vat_rate,0,0,0,'HT',0);
// Calcul du total ht sans remise
$total_ht = $resultarray[0];
@ -123,14 +123,14 @@ class Facturation
$total_ttc = $resultarray[2];
// Calcul du montant de la remise
if ($this->remise_percent())
if ($this->remisePercent())
{
$remise_percent = $this->remise_percent();
$remise_percent = $this->remisePercent();
} else {
$remise_percent = 0;
}
$montant_remise_ht = ($resultarray[6] - $resultarray[0]);
$this->montant_remise($montant_remise_ht);
$this->montantRemise($montant_remise_ht);
$product = new Product($db);
$product->fetch($this->id);
@ -234,8 +234,8 @@ class Facturation
$this->ref('RESET');
$this->qte('RESET');
$this->stock('RESET');
$this->remise_percent('RESET');
$this->montant_remise('RESET');
$this->remisePercent('RESET');
$this->montantRemise('RESET');
$this->prix('RESET');
$this->tva('RESET');
}
@ -245,13 +245,13 @@ class Facturation
*
* @return void
*/
public function raz_pers()
private function razPers()
{
$this->num_facture('RESET');
$this->numInvoice('RESET');
$this->getSetPaymentMode('RESET');
$this->montant_encaisse('RESET');
$this->montant_rendu('RESET');
$this->paiement_le('RESET');
$this->montantEncaisse('RESET');
$this->montantRendu('RESET');
$this->paiementLe('RESET');
$this->prix_total_ht('RESET');
$this->montant_tva('RESET');
@ -368,7 +368,7 @@ class Facturation
* @param string $aRemisePercent Discount
* @return string Discount
*/
public function remise_percent($aRemisePercent=null)
public function remisePercent($aRemisePercent=null)
{
if ( !$aRemisePercent )
@ -392,7 +392,7 @@ class Facturation
* @param int $aMontantRemise Amount
* @return string Amount
*/
public function montant_remise($aMontantRemise=null)
public function montantRemise($aMontantRemise=null)
{
if ( !$aMontantRemise ) {
@ -467,7 +467,7 @@ class Facturation
* @param string $aNumFacture Invoice ref
* @return string Invoice ref
*/
public function num_facture( $aNumFacture=null )
public function numInvoice( $aNumFacture=null )
{
if ( !$aNumFacture ) {
@ -516,7 +516,7 @@ class Facturation
* @param int $aMontantEncaisse Amount
* @return int Amount
*/
public function montant_encaisse( $aMontantEncaisse=null )
public function montantEncaisse( $aMontantEncaisse=null )
{
if ( !$aMontantEncaisse ) {
@ -541,7 +541,7 @@ class Facturation
* @param int $aMontantRendu Amount
* @return int Amount
*/
public function montant_rendu( $aMontantRendu=null )
public function montantRendu( $aMontantRendu=null )
{
if ( !$aMontantRendu ) {
@ -565,7 +565,7 @@ class Facturation
* @param date $aPaiementLe Date
* @return date Date
*/
public function paiement_le( $aPaiementLe=null )
public function paiementLe( $aPaiementLe=null )
{
if ( !$aPaiementLe ) {

View File

@ -154,9 +154,9 @@ $tab_tva = $ret;
// Reinitialisation du mode de paiement, en cas de retour aux achats apres validation
$obj_facturation->getSetPaymentMode('RESET');
$obj_facturation->montant_encaisse('RESET');
$obj_facturation->montant_rendu('RESET');
$obj_facturation->paiement_le('RESET');
$obj_facturation->montantEncaisse('RESET');
$obj_facturation->montantRendu('RESET');
$obj_facturation->paiementLe('RESET');
// Affichage des templates

View File

@ -36,7 +36,7 @@ switch ( $_GET['action'] )
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot;
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
// Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ...
if ( $_POST['hdnSource'] == 'LISTE' )
{
@ -138,7 +138,7 @@ switch ( $_GET['action'] )
{
$obj_facturation->qte($_POST['txtQte']);
$obj_facturation->tva($_POST['selTva']);
$obj_facturation->remise_percent($_POST['txtRemise']);
$obj_facturation->remisePercent($_POST['txtRemise']);
$obj_facturation->ajoutArticle();
}

View File

@ -25,7 +25,7 @@ $langs->load("main");
<table class="table_resume">
<tr><td class="resume_label"><?php echo $langs->trans("Invoice"); ?></td><td><?php echo $obj_facturation->num_facture(); ?></td></tr>
<tr><td class="resume_label"><?php echo $langs->trans("Invoice"); ?></td><td><?php echo $obj_facturation->numInvoice(); ?></td></tr>
<tr><td class="resume_label"><?php echo $langs->trans("TotalHT"); ?></td><td><?php echo price2num($obj_facturation->prix_total_ht(),'MT').' '.$conf->currency; ?></td></tr>
<?php
// Affichage de la tva par taux
@ -81,18 +81,18 @@ $langs->load("main");
// Affichage des infos en fonction du mode de paiement
if ( $obj_facturation->getsetPaymentMode() == 'DIF' ) {
echo ('<tr><td class="resume_label">'.$langs->trans("DateEcheance").'</td><td>'.$obj_facturation->paiement_le().'</td></tr>');
echo ('<tr><td class="resume_label">'.$langs->trans("DateEcheance").'</td><td>'.$obj_facturation->paiementLe().'</td></tr>');
} else {
echo ('<tr><td class="resume_label">'.$langs->trans("Received").'</td><td>'.price2num($obj_facturation->montant_encaisse(),'MT').' '.$conf->currency.'</td></tr>');
echo ('<tr><td class="resume_label">'.$langs->trans("Received").'</td><td>'.price2num($obj_facturation->montantEncaisse(),'MT').' '.$conf->currency.'</td></tr>');
}
// Affichage du montant rendu (reglement en especes)
if ( $obj_facturation->montant_rendu() ) {
if ( $obj_facturation->montantRendu() ) {
echo ('<tr><td class="resume_label">'.$langs->trans("Change").'</td><td>'.price2num($obj_facturation->montant_rendu(),'MT').' '.$conf->currency.'</td></tr>');
echo ('<tr><td class="resume_label">'.$langs->trans("Change").'</td><td>'.price2num($obj_facturation->montantRendu(),'MT').' '.$conf->currency.'</td></tr>');
}

View File

@ -50,7 +50,7 @@ switch ($action)
$invoice->type=0;
$num=$invoice->getNextNumRef($company);
$obj_facturation->num_facture($num);
$obj_facturation->numInvoice($num);
$obj_facturation->getSetPaymentMode($_POST['hdnChoix']);
@ -63,20 +63,20 @@ switch ($action)
}
if ( $mode_reglement != 'DIF') {
$obj_facturation->montant_encaisse($montant);
$obj_facturation->montantEncaisse($montant);
//Determination de la somme rendue
$total = $obj_facturation->prix_total_ttc();
$encaisse = $obj_facturation->montant_encaisse();
$encaisse = $obj_facturation->montantEncaisse();
$obj_facturation->montant_rendu($encaisse - $total);
$obj_facturation->montantRendu($encaisse - $total);
}
else
{
//$txtDatePaiement=$_POST['txtDatePaiement'];
$datePaiement=dol_mktime(0,0,0,$_POST['txtDatePaiementmonth'],$_POST['txtDatePaiementday'],$_POST['txtDatePaiementyear']);
$txtDatePaiement=dol_print_date($datePaiement,'dayrfc');
$obj_facturation->paiement_le($txtDatePaiement);
$obj_facturation->paiementLe($txtDatePaiement);
}
$redirection = 'affIndex.php?menu=validation';
@ -115,8 +115,8 @@ switch ($action)
$mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement');
$cond_reglement_id = 0;
$note .= $langs->trans("Cash")."\n";
$note .= $langs->trans("Received").' : '.$obj_facturation->montant_encaisse()." ".$conf->currency."\n";
$note .= $langs->trans("Rendu").' : '.$obj_facturation->montant_rendu()." ".$conf->currency."\n";
$note .= $langs->trans("Received").' : '.$obj_facturation->montantEncaisse()." ".$conf->currency."\n";
$note .= $langs->trans("Rendu").' : '.$obj_facturation->montantRendu()." ".$conf->currency."\n";
$note .= "\n";
$note .= '--------------------------------------'."\n\n";
break;
@ -209,10 +209,10 @@ switch ($action)
// Si paiement differe ...
if ( $obj_facturation->getSetPaymentMode() == 'DIF' )
{
$resultcreate=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiement_le()));
$resultcreate=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiementLe()));
if ($resultcreate > 0)
{
$resultvalid=$invoice->validate($user,$obj_facturation->num_facture());
$resultvalid=$invoice->validate($user,$obj_facturation->numInvoice());
}
else
{
@ -226,7 +226,7 @@ switch ($action)
$resultcreate=$invoice->create($user,0,0);
if ($resultcreate > 0)
{
$resultvalid=$invoice->validate($user, $obj_facturation->num_facture(), (isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0));
$resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), (isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0));
$id = $invoice->id;
@ -235,7 +235,7 @@ switch ($action)
$payment->datepaye=$now;
$payment->bank_account=$conf_fkaccount;
$payment->amounts[$invoice->id]=$obj_facturation->prix_total_ttc();
$payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->num_facture();
$payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice();
$payment->paiementid=$invoice->mode_reglement_id;
$payment->num_paiement='';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
@ -38,6 +38,8 @@ $ref = GETPOST('ref');
$type = GETPOST('type');
$mesg = GETPOST('mesg');
$removecat = GETPOST('removecat','int');
$dbtablename = '';
@ -65,6 +67,7 @@ if ($id || $ref)
$elementtype = 'societe';
$objecttype = 'societe&categorie';
$objectid = isset($id)?$id:(isset($socid)?$socid:'');
$dbtablename = '&societe';
$fieldid = 'rowid';
}
if ($type == 3) {
@ -86,7 +89,7 @@ $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid
*/
//Suppression d'un objet d'une categorie
if ($_REQUEST["removecat"])
if ($removecat > 0)
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
@ -112,7 +115,7 @@ if ($_REQUEST["removecat"])
$result = $object->fetch($objectid);
}
$cat = new Categorie($db);
$result=$cat->fetch($_REQUEST["removecat"]);
$result=$cat->fetch($removecat);
$result=$cat->del_type($object,$elementtype);
}
@ -269,11 +272,11 @@ if ($socid)
dol_htmloutput_mesg($mesg);
if ($soc->client) formCategory($db,$soc,2);
if ($soc->client) formCategory($db,$soc,2,$socid);
if ($soc->client && $soc->fournisseur) print '<br><br>';
if ($soc->fournisseur) formCategory($db,$soc,1);
if ($soc->fournisseur) formCategory($db,$soc,1,$socid);
}
else if ($id || $ref)
{
@ -423,7 +426,7 @@ else if ($id || $ref)
* @param int $typeid Type of category (0, 1, 2, 3)
* @return int 0
*/
function formCategory($db,$object,$typeid)
function formCategory($db,$object,$typeid,$socid=0)
{
global $user,$langs,$form,$bc;
@ -498,7 +501,7 @@ function formCategory($db,$object,$typeid)
if ($typeid == 3) $permission=$user->rights->adherent->creer;
if ($permission)
{
print "<a href= '".DOL_URL_ROOT."/categories/categorie.php?".(empty($_REQUEST["socid"])?'id':'socid')."=".$object->id.(empty($_REQUEST["socid"])?"&amp;type=".$typeid."&amp;typeid=".$typeid:'')."&amp;removecat=".$cat->id."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removecat=".$cat->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
@ -529,7 +532,7 @@ function formCategory($db,$object,$typeid)
return 0;
}
$db->close();
llxFooter();
?>
$db->close();
?>

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2005 Davoleau Brice <brice.davoleau@gmail.com>
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
*
@ -125,6 +125,7 @@ class Categorie
* @return int -1 : erreur SQL
* -2 : nouvel ID inconnu
* -3 : categorie invalide
* -4 : category already exists
*/
function create($user='')
{
@ -141,8 +142,10 @@ class Categorie
{
$this->error=$langs->trans("ImpossibleAddCat");
$this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel");
return -1;
return -4;
}
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description,";
if ($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
@ -176,7 +179,8 @@ class Categorie
if($this->add_fille() < 0)
{
$this->error=$langs->trans("ImpossibleAssociateCategory");
return -1;
$this->db->rollback();
return -3;
}
}
@ -186,17 +190,21 @@ class Categorie
$result=$interface->run_triggers('CATEGORY_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
$this->db->commit();
return $id;
}
else
{
$this->db->rollback();
return -2;
}
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
dol_syslog(get_class($this)."::create error ".$this->error." sql=".$sql, LOG_ERR);
$this->db->rollback();
return -1;
}
}
@ -589,11 +597,11 @@ class Categorie
*/
function get_desc($cate)
{
$sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie ";
$sql .= "WHERE rowid = ".$cate;
$sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE rowid = ".$cate;
$res = $this->db->query($sql);
$n = $this->db->fetch_array($res);
$res = $this->db->query($sql);
$n = $this->db->fetch_array($res);
return($n[0]);
}
@ -632,8 +640,6 @@ class Categorie
*/
function get_full_arbo($type,$markafterid=0)
{
global $conf;
$this->cats = array();
// Charge tableau des meres
@ -641,7 +647,7 @@ class Categorie
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_association ca";
$sql.= ", ".MAIN_DB_PREFIX."categorie as c";
$sql.= " WHERE ca.fk_categorie_mere = c.rowid";
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('category',1).")";
// Load array this->motherof
dol_syslog("Categorie::get_full_arbo build motherof array sql=".$sql, LOG_DEBUG);
@ -665,7 +671,7 @@ class Categorie
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_association as ca";
$sql.= " ON c.rowid = ca.fk_categorie_mere";
$sql.= " WHERE c.type = ".$type;
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.entity IN (".getEntity('category',1).")";
$sql.= " ORDER BY c.label, c.rowid";
dol_syslog("Categorie::get_full_arbo get category list sql=".$sql, LOG_DEBUG);
@ -811,6 +817,7 @@ class Categorie
function get_all_categories ()
{
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE entity IN (".getEntity('category',1).")";
$res = $this->db->query($sql);
if ($res)
@ -839,6 +846,7 @@ class Categorie
{
$sql = "SELECT count(rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE entity IN (".getEntity('category',1).")";
$res = $this->db->query($sql);
if ($res)
{
@ -870,6 +878,7 @@ class Categorie
$sql.= " ON c.rowid=ca.fk_categorie_fille";
$sql.= " WHERE ca.fk_categorie_mere=".$this->id_mere;
$sql.= " AND c.label='".$this->db->escape($this->label)."'";
$sql.= " AND c.entity IN (".getEntity('category',1).")";
}
else // mother_id undefined (so it's root)
{
@ -883,8 +892,9 @@ class Categorie
$sql.= " ON c.rowid!=ca.fk_categorie_fille";
$sql.= " WHERE c.type=".$this->type;
$sql.= " AND c.label='".$this->db->escape($this->label)."'";
$sql.= " AND c.entity IN (".getEntity('category',1).")";
}
dol_syslog("Categorie::already_exists sql=".$sql);
dol_syslog(get_class($this)."::already_exists sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -896,13 +906,19 @@ class Categorie
* So if the result have the same id, update is not for label, and if result have an other one,
* update may be for label.
*/
if($obj[0] > 0 && $obj[0] != $this->id) return 1;
if($obj[0] > 0 && $obj[0] != $this->id)
{
dol_syslog(get_class($this)."::already_exists category with name=".$this->label." exist rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG);
return 1;
}
}
dol_syslog(get_class($this)."::already_exists no category with same name=".$this->label." rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG);
return 0;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
dol_syslog(get_class($this)."::already_exists error ".$this->error." sql=".$sql, LOG_ERR);
return -1;
}
}
@ -1101,6 +1117,7 @@ class Categorie
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON ct.fk_categorie = c.rowid";
$sql.= " WHERE ct.fk_".$table." = ".$id." AND c.type = ".$typeid;
$sql.= " AND c.entity IN (".getEntity('category',1).")";
$res = $this->db->query($sql);
if ($res)
@ -1135,8 +1152,9 @@ class Categorie
$cats = array ();
// Generation requete recherche
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie ";
$sql .= "WHERE type = ".$type." ";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE type = ".$type." ";
$sql.= " AND entity IN (".getEntity('category',1).")";
if ($nom)
{
if (! $exact)

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
@ -41,7 +41,7 @@ if ($id == "")
}
// Security check
$result = restrictedArea($user, 'categorie', $id);
$result = restrictedArea($user, 'categorie', $id, '&category');

View File

@ -3,7 +3,7 @@
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -29,12 +29,13 @@ require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/treeview.lib.php");
$type=(GETPOST('type') ? GETPOST('type') : 0);
if (!$user->rights->categorie->lire) accessforbidden();
$langs->load("categories");
if (! $user->rights->categorie->lire) accessforbidden();
$id=GETPOST('id','int');
$type=(GETPOST('type') ? GETPOST('type') : 0);
/*
* View
@ -88,9 +89,9 @@ print '</td><td valign="top" width="70%">';
/*
* Categories found
*/
if($_POST['catname'] || $_REQUEST['id'])
if($_POST['catname'] || $id > 0)
{
$cats = $categstatic->rechercher($_REQUEST['id'],$_POST['catname'],$_POST['type']);
$cats = $categstatic->rechercher($id,$_POST['catname'],$type);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FoundCats").'</td></tr>';
@ -235,8 +236,7 @@ foreach($fulltree as $key => $val)
$resarray=tree_showpad($fulltree,$key);
$a=$resarray[0];
$nbofsubdir=$resarray[1];
$c=$resarray[2];
$nboffilesinsubdir=$resarray[3];
$nboffilesinsubdir=$resarray[2];
print '</td>';
// Show picto
@ -309,7 +309,7 @@ if ($nbofentries == 0)
print "</table>";
$db->close();
llxFooter();
$db->close();
?>

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -48,7 +48,7 @@ if ($id == "")
}
// Security check
$result = restrictedArea($user, 'categorie', $id);
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -44,7 +44,7 @@ if ($id == "")
}
// Security check
$result = restrictedArea($user, 'categorie', $id);
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
$result=$object->fetch($id);

View File

@ -201,19 +201,6 @@ if ($action == 'create')
}
print '</td></tr>';
// Delivery address
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS)
{
print '<tr><td>'.$langs->trans('DeliveryAddress').'</td>';
print '<td colspan="3">';
$numaddress = $form->select_address($soc->fk_delivery_address, $_GET['socid'],'fk_address',1);
if ($numaddress==0)
{
print ' &nbsp; <a href=../comm/address.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddAddress").'</a>';
}
print '</td></tr>';
}
// Model
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -20,7 +20,7 @@
/**
* \file htdocs/comm/address.php
* \ingroup societe
* \brief Tab address of customer
* \brief Tab address of thirdparty
*/
require("../main.inc.php");
@ -31,58 +31,73 @@ require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php");
$langs->load("companies");
$langs->load("commercial");
$id = isset($_GET["id"])?$_GET["id"]:'';
$origin = isset($_GET["origin"])?$_GET["origin"]:'';
$originid = isset($_GET["originid"])?$_GET["originid"]:'';
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
if (! $socid && ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add' && $_REQUEST["action"] != 'update')) accessforbidden();
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$backtopage = GETPOST('backtopage','alpha');
$origin = GETPOST('origin','alpha');
$originid = GETPOST('originid','int');
$socid = GETPOST('socid','int');
if (! $socid && ($action != 'create' && $action != 'add' && $action != 'update')) accessforbidden();
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid);
$object = new Address($db);
/*
* Actions
*/
if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
// Cancel
if (GETPOST("cancel") && ! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
if ($action == 'add' || $action == 'update')
{
$address = new Address($db);
$address->socid = $_POST["socid"];
$address->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:'');
$address->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:'');
$address->address = $_POST["address"];
$address->cp = $_POST["zipcode"];
$address->ville = $_POST["town"];
$address->zip = $_POST["zipcode"];
$address->town = $_POST["town"];
$address->pays_id = $_POST["country_id"];
$address->country_id= $_POST["country_id"];
$address->tel = $_POST["tel"];
$address->fax = $_POST["fax"];
$address->note = $_POST["note"];
if ($_POST["action"] == 'add')
$object->socid = $socid;
$object->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:'');
$object->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:'');
$object->address = $_POST["address"];
$object->zip = $_POST["zipcode"];
$object->town = $_POST["town"];
$object->country_id = $_POST["country_id"];
$object->phone = $_POST["phone"];
$object->fax = $_POST["fax"];
$object->note = $_POST["note"];
// Add new address
if ($action == 'add')
{
$socid = $_POST["socid"];
$origin = $_POST["origin"];
$originid = $_POST["originid"];
$result = $address->create($socid, $user);
$result = $object->create($socid, $user);
if ($result >= 0)
{
if ($origin == 'commande')
if (! empty($backtopage))
{
Header("Location: ".$backtopage);
exit;
}
else if ($origin == 'commande')
{
Header("Location: ../commande/fiche.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
Header("Location: ../commande/contact.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
exit;
}
elseif ($origin == 'propal')
{
Header("Location: ../comm/propal.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
Header("Location: ../comm/propal/contact.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
exit;
}
elseif ($origin == 'shipment')
{
Header("Location: ../expedition/fiche.php?id=".$originid);
exit;
}
else
{
Header("Location: ".$_SERVER['PHP_SELF']."?socid=".$socid);
@ -91,28 +106,31 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
}
else
{
$mesg = $address->error;
$_GET["action"]='create';
$mesg = $object->error;
$action='create';
}
}
if ($_POST["action"] == 'update')
// Update address
else if ($action == 'update')
{
$socid = $_POST["socid"];
$origin = $_POST["origin"];
$originid = $_POST["originid"];
$result = $address->update($_POST["id"], $socid, $user);
$result = $object->update($_POST["id"], $socid, $user);
if ($result >= 0)
{
if ($origin == 'commande')
if (! empty($backtopage))
{
Header("Location: ".$backtopage);
exit;
}
else if ($origin == 'commande')
{
Header("Location: ../commande/fiche.php?id=".$originid);
Header("Location: ../commande/contact.php?id=".$originid);
exit;
}
elseif ($origin == 'propal')
{
Header("Location: ../comm/propal.php?id=".$originid);
Header("Location: ../comm/propal/contact.php?id=".$originid);
exit;
}
elseif ($origin == 'shipment')
@ -129,17 +147,16 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
else
{
$reload = 0;
$mesg = $address->error;
$_GET["action"]= "edit";
$mesg = $object->error;
$actino= "edit";
}
}
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->supprimer)
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer)
{
$address = new Address($db);
$result = $address->delete($_GET["id"], $socid);
$result = $object->delete($id, $socid);
if ($result == 0)
{
@ -149,7 +166,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user-
else
{
$reload = 0;
$_GET["action"]='';
$action='';
}
}
@ -167,7 +184,7 @@ $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("Se
dol_htmloutput_errors($mesg);
if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
if ($action == 'create')
{
if ($user->rights->societe->creer)
{
@ -175,132 +192,122 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
* Creation
*/
$address = new Address($db);
$societe=new Societe($db);
$societe->fetch($socid);
$head = societe_prepare_head($societe);
dol_fiche_head($head, 'customer', $societe->nom);
if ($_POST["label"] && $_POST["name"])
{
$address->socid = $_POST["socid"];
$address->label = $_POST["label"];
$address->name = $_POST["name"];
$address->address = $_POST["address"];
$address->cp = $_POST["zipcode"];
$address->ville = $_POST["town"];
$address->tel = $_POST["tel"];
$address->fax = $_POST["fax"];
$address->note = $_POST["note"];
$object->socid = $socid;
$object->label = $_POST["label"];
$object->name = $_POST["name"];
$object->address = $_POST["address"];
$object->zip = $_POST["zipcode"];
$object->town = $_POST["town"];
$object->phone = $_POST["phone"];
$object->fax = $_POST["fax"];
$object->note = $_POST["note"];
}
// On positionne pays_id, pays_code et libelle du pays choisi
$address->country_id=$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
if ($address->country_id)
$object->country_id = (GETPOST('country_id','int') ? GETPOST('country_id','int') : $mysoc->country_id);
if ($object->country_id)
{
$tmparray=getCountry($address->country_id,'all');
$address->pays_code = $tmparray['code'];
$address->pays = $tmparray['label'];
$address->country_code = $tmparray['code'];
$address->country = $tmparray['label'];
$tmparray=getCountry($object->country_id,'all');
$object->country_code = $tmparray['code'];
$object->country = $tmparray['label'];
}
print_fiche_titre($langs->trans("AddAddress"));
print_titre($langs->trans("AddAddress"));
print "<br>\n";
if ($address->error)
{
print '<div class="error">';
print nl2br($address->error);
print '</div>';
}
// If javascript enabled, we add interactivity on mandatory fields
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
jQuery("#label").focus(function() {
print '$(document).ready(function () {
$("#label").focus(function() {
hideMessage("label","'.$langs->trans('RequiredField').'");
});
jQuery("#label").blur(function() {
$("#label").blur(function() {
displayMessage("label","'.$langs->trans('RequiredField').'");
});
jQuery("#name").focus(function() {
$("#name").focus(function() {
hideMessage("name","'.$langs->trans('RequiredField').'");
});
jQuery("#name").blur(function() {
$("#name").blur(function() {
displayMessage("name","'.$langs->trans('RequiredField').'");
});
displayMessage("label","'.$langs->trans('RequiredField').'");
displayMessage("name","'.$langs->trans('RequiredField').'");
jQuery("#label").css("color","grey");
jQuery("#name").css("color","grey");
$("#label").css("color","grey");
$("#name").css("color","grey");
})';
print '</script>'."\n";
}
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST" name="formsoc">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="socid" value="'.$socid.'">';
print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'"/>';
print '<input type="hidden" name="socid" value="'.$socid.'"/>';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'"/>';
print '<input type="hidden" name="origin" value="'.$origin.'"/>';
print '<input type="hidden" name="originid" value="'.$originid.'"/>';
print '<input type="hidden" name="action" value="add"/>';
print '<table class="border" width="100%">';
print '<tr><td class="fieldrequired">'.$langs->trans('Label').'</td><td><input type="text" size="30" name="label" id="label" value="'.($address->label?$address->label:$langs->trans('RequiredField')).'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Name').'</td><td><input type="text" size="30" name="name" id="name" value="'.($address->name?$address->name:$langs->trans('RequiredField')).'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Label').'</td><td><input type="text" size="30" name="label" id="label" value="'.($object->label?$object->label:$langs->trans('RequiredField')).'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Name').'</td><td><input type="text" size="30" name="name" id="name" value="'.($object->name?$object->name:$langs->trans('RequiredField')).'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="40" rows="3" wrap="soft">';
print $address->address;
print $object->address;
print '</textarea></td></tr>';
// Zip
print '<tr><td>'.$langs->trans('Zip').'</td><td>';
print $formcompany->select_ziptown($address->cp,'zipcode',array('town','selectcountry_id'),6);
print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id'),6);
print '</td></tr>';
// Town
print '<tr><td>'.$langs->trans('Town').'</td><td>';
print $formcompany->select_ziptown($address->ville,'town',array('zipcode','selectcountry_id'));
print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id'));
print '</td></tr>';
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
print $form->select_country($address->country_id,'selectcountry_id');
print $form->select_country($object->country_id,'selectcountry_id');
print '</td></tr>';
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$address->tel.'"></td></tr>';
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="phone" value="'.$object->phone.'"></td></tr>';
print '<tr><td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$address->fax.'"></td></tr>';
print '<tr><td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$object->fax.'"></td></tr>';
print '<tr><td>'.$langs->trans('Note').'</td><td colspan="3"><textarea name="note" cols="40" rows="6" wrap="soft">';
print $address->note;
print $object->note;
print '</textarea></td></tr>';
print '</table>'."\n";
print '<br><center>';
print '<input type="submit" class="button" value="'.$langs->trans('AddAddress').'"></center>'."\n";
print '<input type="submit" class="button" value="'.$langs->trans('Add').'">';
if (! empty($backtopage))
{
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
}
print '</center>'."\n";
print '</form>'."\n";
}
}
elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
elseif ($action == 'edit')
{
/*
* Fiche societe en mode edition
*/
$address = new Address($db);
$societe=new Societe($db);
$societe->fetch($_GET["socid"]);
$societe->fetch($socid);
$head = societe_prepare_head($societe);
dol_fiche_head($head, 'customer', $societe->nom);
dol_fiche_head($head, 'card', $societe->nom);
print_titre($langs->trans("EditAddress"));
print "<br>\n";
@ -309,83 +316,80 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
{
if ($reload || ! $_POST["name"])
{
$address->socid = $socid;
$address->fetch_address($id);
$object->socid = $socid;
$object->fetch_address($id);
}
else
{
$address->id = $_POST["id"];
$address->socid = $_POST["socid"];
$address->label = $_POST["label"];
$address->name = $_POST["name"];
$address->address = $_POST["address"];
$address->cp = $_POST["zipcode"];
$address->ville = $_POST["town"];
$address->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
$address->tel = $_POST["tel"];
$address->fax = $_POST["fax"];
$address->note = $_POST["note"];
$object->id = $id;
$object->socid = $socid;
$object->label = $_POST["label"];
$object->name = $_POST["name"];
$object->address = $_POST["address"];
$object->zip = $_POST["zipcode"];
$object->town = $_POST["town"];
$object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
$object->phone = $_POST["phone"];
$object->fax = $_POST["fax"];
$object->note = $_POST["note"];
// On positionne country_id, pays_code et libelle du pays choisi
if ($address->country_id)
if ($object->country_id)
{
$tmparray=getCountry($address->country_id,'all');
$address->pays_code = $tmparray['code'];
$address->pays = $tmparray['label'];
$address->country_code = $tmparray['code'];
$address->country = $tmparray['label'];
$tmparray=getCountry($object->country_id,'all');
$object->country_code = $tmparray['code'];
$object->country = $tmparray['label'];
}
}
if ($address->error)
{
print '<div class="error">';
print $address->error;
print '</div>';
}
print '<form action="'.$_SERVER['PHP_SELF'].'?socid='.$address->socid.'" method="POST" name="formsoc">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="socid" value="'.$address->socid.'">';
print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">';
print '<input type="hidden" name="id" value="'.$address->id.'">';
print '<form action="'.$_SERVER['PHP_SELF'].'?socid='.$object->socid.'" method="POST" name="formsoc">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'"/>';
print '<input type="hidden" name="action" value="update"/>';
print '<input type="hidden" name="socid" value="'.$object->socid.'"/>';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'"/>';
print '<input type="hidden" name="origin" value="'.$origin.'"/>';
print '<input type="hidden" name="originid" value="'.$originid.'"/>';
print '<input type="hidden" name="id" value="'.$object->id.'"/>';
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans('AddressLabel').'</td><td colspan="3"><input type="text" size="40" name="label" value="'.$address->label.'"></td></tr>';
print '<tr><td>'.$langs->trans('Name').'</td><td colspan="3"><input type="text" size="40" name="name" value="'.$address->name.'"></td></tr>';
print '<tr><td>'.$langs->trans('AddressLabel').'</td><td colspan="3"><input type="text" size="40" name="label" value="'.$object->label.'"></td></tr>';
print '<tr><td>'.$langs->trans('Name').'</td><td colspan="3"><input type="text" size="40" name="name" value="'.$object->name.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="40" rows="3" wrap="soft">';
print $address->address;
print $object->address;
print '</textarea></td></tr>';
// Zip
print '<tr><td>'.$langs->trans('Zip').'</td><td>';
print $formcompany->select_ziptown($address->cp,'zipcode',array('town','selectcountry_id'),6);
print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id'),6);
print '</td></tr>';
// Town
print '<tr><td>'.$langs->trans('Town').'</td><td>';
print $formcompany->select_ziptown($address->ville,'town',array('zipcode','selectcountry_id'));
print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id'));
print '</td></tr>';
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
print $form->select_country($address->country_id,'country_id');
print $form->select_country($object->country_id,'country_id');
print '</td></tr>';
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$address->tel.'"></td></tr>';
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="phone" value="'.$object->phone.'"></td></tr>';
print '<tr><td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$address->fax.'"></td></tr>';
print '<tr><td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$object->fax.'"></td></tr>';
print '<tr><td>'.$langs->trans('Note').'</td><td colspan="3"><textarea name="note" cols="40" rows="6" wrap="soft">';
print $address->note;
print $object->note;
print '</textarea></td></tr>';
print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
print '</table>';
print '</table><br>';
print '<center>';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</center>';
print '</form>';
}
}
@ -394,37 +398,30 @@ else
/*
* Fiche societe en mode visu
*/
$address = new Address($db);
$result=$address->fetch_lines($socid);
$result=$object->fetch_lines($socid);
if ($result < 0)
{
dol_print_error($db,$address->error);
dol_print_error($db,$object->error);
exit;
}
$societe=new Societe($db);
$societe->fetch($address->socid);
$societe->fetch($object->socid);
$head = societe_prepare_head($societe);
dol_fiche_head($head, 'customer', $societe->nom);
// Confirmation delete
if ($_GET["action"] == 'delete')
if ($action == 'delete')
{
$form = new Form($db);
$ret=$form->form_confirm($_SERVER['PHP_SELF']."?socid=".$address->socid."&amp;id=".$_GET["id"],$langs->trans("DeleteAddress"),$langs->trans("ConfirmDeleteAddress"),"confirm_delete");
$ret=$form->form_confirm($_SERVER['PHP_SELF']."?socid=".$object->socid."&amp;id=".$id,$langs->trans("DeleteAddress"),$langs->trans("ConfirmDeleteAddress"),"confirm_delete");
if ($ret == 'html') print '<br>';
}
if ($address->error)
{
print '<div class="error">';
print $address->error;
print '</div>';
}
$nblines = count($address->lines);
$nblines = count($object->lines);
if ($nblines)
{
for ($i = 0 ; $i < $nblines ; $i++)
@ -432,20 +429,20 @@ else
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans('AddressLabel').'</td><td colspan="3">'.$address->lines[$i]->label.'</td>';
print '<td valign="top" colspan="2" width="50%" rowspan="6">'.$langs->trans('Note').' :<br>'.nl2br($address->lines[$i]->note).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td colspan="3">'.$address->lines[$i]->name.'</td></tr>';
print '<tr><td width="20%">'.$langs->trans('AddressLabel').'</td><td colspan="3">'.$object->lines[$i]->label.'</td>';
print '<td valign="top" colspan="2" width="50%" rowspan="6">'.$langs->trans('Note').' :<br>'.nl2br($object->lines[$i]->note).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td colspan="3">'.$object->lines[$i]->name.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($address->lines[$i]->address)."</td></tr>";
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($object->lines[$i]->address)."</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$address->lines[$i]->cp."</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$address->lines[$i]->ville."</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$object->lines[$i]->zip."</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$object->lines[$i]->town."</td></tr>";
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$address->lines[$i]->pays.'</td>';
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$object->lines[$i]->country.'</td>';
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($address->lines[$i]->tel,$address->lines[$i]->country_code,0,$address->socid,'AC_TEL').'</td></tr>';
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($object->lines[$i]->phone,$object->lines[$i]->country_code,0,$object->socid,'AC_TEL').'</td></tr>';
print '<tr><td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($address->lines[$i]->fax,$address->lines[$i]->country_code,0,$address->socid,'AC_FAX').'</td></tr>';
print '<tr><td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($object->lines[$i]->fax,$object->lines[$i]->country_code,0,$object->socid,'AC_FAX').'</td></tr>';
print '</td></tr>';
@ -460,12 +457,12 @@ else
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$address->socid.'&amp;id='.$address->lines[$i]->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->socid.'&amp;id='.$object->lines[$i]->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
}
if ($user->rights->societe->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?socid='.$address->socid.'&amp;id='.$address->lines[$i]->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->socid.'&amp;id='.$object->lines[$i]->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
@ -484,21 +481,21 @@ else
* Bouton actions
*/
if ($_GET["action"] == '')
if ($action == '')
{
print '<div class="tabsAction">';
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$address->socid.'&amp;action=create">'.$langs->trans("Add").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->socid.'&amp;action=create">'.$langs->trans("Add").'</a>';
}
print '</div>';
}
}
$db->close();
// End of page
llxFooter();
$db->close();
?>

View File

@ -125,8 +125,9 @@ $resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
print_barre_liste($langs->trans("ListOfContacts").($label?" (".$label.")":""),$page, $_SERVER["PHP_SELF"], "&amp;type=$type",$sortfield,$sortorder,"",$num);
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
print_barre_liste($title.($label?" (".$label.")":""),$page, $_SERVER["PHP_SELF"], "&amp;type=$type",$sortfield,$sortorder,"",$num);
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';

View File

@ -37,7 +37,6 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/co
if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
if ($conf->adherent->enabled) require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
if ($conf->ficheinter->enabled) require_once(DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php");
if (!empty($conf->global->MAIN_MODULE_CHRONODOCS)) require_once(DOL_DOCUMENT_ROOT."/chronodocs/chronodocs_entries.class.php");
$langs->load("companies");
if ($conf->contrat->enabled) $langs->load("contracts");
@ -46,7 +45,6 @@ if ($conf->facture->enabled) $langs->load("bills");
if ($conf->projet->enabled) $langs->load("projects");
if ($conf->ficheinter->enabled) $langs->load("interventions");
if ($conf->notification->enabled) $langs->load("mails");
if (!empty($conf->global->MAIN_MODULE_CHRONODOCS)) $langs->load("chronodocs");
// Security check
$id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
@ -85,34 +83,19 @@ if ($action == 'setcustomeraccountancycode')
$action="";
}
if ($action == 'attribute_prefix' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->attribute_prefix($db, $id);
}
// conditions de reglement
if ($action == 'setconditions' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->cond_reglement=$_POST['cond_reglement_id'];
// TODO move to DAO class
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET cond_reglement='".$_POST['cond_reglement_id'];
$sql.= "' WHERE rowid='".$id."'";
$result = $db->query($sql);
if (! $result) dol_print_error($result);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// mode de reglement
if ($action == 'setmode' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->mode_reglement=$_POST['mode_reglement_id'];
// TODO move to DAO class
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET mode_reglement='".$_POST['mode_reglement_id'];
$sql.= "' WHERE rowid='".$id."'";
$result = $db->query($sql);
if (! $result) dol_print_error($result);
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// assujetissement a la TVA
if ($action == 'setassujtva' && $user->rights->societe->creer)
@ -382,42 +365,6 @@ if ($id > 0)
print '</tr>';
}
// Old way to define delivery address (deprecated).
// Now all addresses types (like delivery addresses, invoices addresses,...) are saved as contacts.
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) // Hidden deprecated feature.
{
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans("DeliveriesAddress");
print '<td><td align="right">';
if ($user->rights->societe->creer)
{
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td><td colspan="3">';
// TODO move to DAO class
$sql = "SELECT count(rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_address";
$sql.= " WHERE fk_soc =".$object->id;
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$objal = $db->fetch_object($resql);
print $objal->nb?($objal->nb):$langs->trans("NoOtherDeliveryAddress");
}
else
{
dol_print_error($db);
}
print '</td>';
print '</tr>';
}
// Module Adherent
if ($conf->adherent->enabled)
{
@ -839,11 +786,6 @@ if ($id > 0)
}
}
/*if ($user->rights->societe->contact->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContact").'</a>';
}*/
print '</div>';
print "<br>\n";
@ -853,6 +795,12 @@ if ($id > 0)
// List of contacts
show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
// Addresses list
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB))
{
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
@ -871,7 +819,7 @@ else
}
// End of page
llxFooter();
$db->close();
?>

View File

@ -515,7 +515,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
print '</td>';
print '<td width="16" align="center" class="nobordernopadding">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
$formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1);
print '</td></tr></table>';

View File

@ -77,9 +77,10 @@ class Mailing extends CommonObject
}
/**
* \brief Create an EMailing
* \param user Object of user making creation
* \return -1 if error, Id of created object if OK
* Create an EMailing
*
* @param User $user Object of user making creation
* @return int -1 if error, Id of created object if OK
*/
function create($user)
{
@ -133,9 +134,10 @@ class Mailing extends CommonObject
}
/**
* \brief Update emailing record
* \param user Object of user making change
* \return < 0 if KO, > 0 if OK
* Update emailing record
*
* @param User $user Object of user making change
* @return int < 0 if KO, > 0 if OK
*/
function update($user)
{
@ -165,9 +167,10 @@ class Mailing extends CommonObject
}
/**
* \brief Get object from database
* \param rowid id du mailing
* \return int
* Get object from database
*
* @param int $rowid Id of emailing
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid)
{
@ -227,9 +230,10 @@ class Mailing extends CommonObject
/**
* \brief Load an object from its id and create a new one in database
* \param fromid Id of object to clone
* \return int New id of clone
* 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
*/
function createFromClone($fromid,$option1,$option2)
{
@ -303,9 +307,10 @@ class Mailing extends CommonObject
}
/**
* \brief Validate emailing
* \param user Objet user qui valide
* \return int <0 if KO, >0 if OK
* Validate emailing
*
* @param User $user Objet user qui valide
* @return int <0 if KO, >0 if OK
*/
function valid($user)
{
@ -328,9 +333,10 @@ class Mailing extends CommonObject
/**
* \brief Delete emailing
* \param rowid id du mailing a supprimer
* \return int 1 en cas de succes
* Delete emailing
*
* @param int $rowid id du mailing a supprimer
* @return int 1 en cas de succes
*/
function delete($rowid)
{
@ -353,9 +359,10 @@ class Mailing extends CommonObject
/**
* \brief Change status of each recipient
* \param user Objet user qui valide
* \return int <0 if KO, >0 if OK
* Change status of each recipient
*
* @param User $user Objet user qui valide
* @return int <0 if KO, >0 if OK
*/
function reset_targets_status($user)
{
@ -379,9 +386,10 @@ class Mailing extends CommonObject
/**
* \brief Retourne le libelle du statut d'un mailing (brouillon, validee, ...
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* \return string Libelle
* Retourne le libelle du statut d'un mailing (brouillon, validee, ...
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* @return string Label
*/
function getLibStatut($mode=0)
{
@ -389,10 +397,11 @@ class Mailing extends CommonObject
}
/**
* \brief Renvoi le libelle d'un statut donn<EFBFBD>
* \param statut Id statut
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* \return string Libelle du statut
* Renvoi le libelle d'un statut donne
*
* @param int $statut Id statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label
*/
function LibStatut($statut,$mode=0)
{

View File

@ -48,7 +48,9 @@ $substitutionarray=array(
'__OTHER2__' => 'Other2',
'__OTHER3__' => 'Other3',
'__OTHER4__' => 'Other4',
'__OTHER5__' => 'Other5'
'__OTHER5__' => 'Other5',
'__SIGNATURE__' => 'Signature',
'__PERSONALIZED__' => 'Personalized'
);
$substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord',
@ -61,7 +63,9 @@ $substitutionarrayfortest=array(
'__OTHER2__' => 'TESTOther2',
'__OTHER3__' => 'TESTOther3',
'__OTHER4__' => 'TESTOther4',
'__OTHER5__' => 'TESTOther5'
'__OTHER5__' => 'TESTOther5',
'__SIGNATURE__' => 'TESTSignature',
'__PERSONALIZED__' => 'TESTPersonalized'
);
@ -192,7 +196,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes')
'__OTHER4__' => $other4,
'__OTHER5__' => $other5
);
$substitutionisok=true;
complete_substitutions_array($substitutionarray, $langs);
$newsubject=make_substitutions($subject,$substitutionarray);

View File

@ -66,8 +66,6 @@ $month=GETPOST("month");
// Nombre de ligne pour choix de produit/service predefinis
$NBLINES=4;
$object = new Propal($db);
// Security check
$module='propale';
if (isset($socid))
@ -85,6 +83,14 @@ else if (isset($id) && $id > 0)
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, $module, $objectid, $dbtable);
$object = new Propal($db);
// Load object
if ($id > 0 || ! empty($ref))
{
$ret=$object->fetch($id, $ref);
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($db);
@ -144,39 +150,32 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop
}
// Remove line
else if ($action == 'confirm_deleteline' && $confirm == 'yes')
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer)
{
if ($user->rights->propale->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($lineid);
// reorder lines
if ($result) $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
else
{
$mesg='<div class="error">'.$object->error.'</div>';
}
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($lineid);
// reorder lines
if ($result) $object->line_order(true);
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
// Validation
@ -210,7 +209,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr
}
}
else if ($action == 'setdate')
else if ($action == 'setdate' && $user->rights->propale->creer)
{
$datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
@ -227,26 +226,19 @@ else if ($action == 'setdate')
if ($result < 0) dol_print_error($db,$object->error);
}
}
else if ($action == 'setecheance')
else if ($action == 'setecheance' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setdate_livraison')
else if ($action == 'setdate_livraison' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setaddress' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->set_adresse_livraison($user,$_POST['fk_address']);
if ($result < 0) dol_print_error($db,$object->error);
}
// Positionne ref client
else if ($action == 'set_ref_client' && $user->rights->propale->creer)
{
@ -254,6 +246,20 @@ else if ($action == 'set_ref_client' && $user->rights->propale->creer)
$object->set_ref_client($user, $_POST['ref_client']);
}
else if ($action == 'setnote_public' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
// Create proposal
else if ($action == 'add' && $user->rights->propale->creer)
{
@ -396,7 +402,7 @@ else if ($action == 'add' && $user->rights->propale->creer)
}
// Classify billed
else if ($action == 'classifybilled')
else if ($action == 'classifybilled' && $user->rights->propale->cloturer)
{
$object->fetch($id);
$object->cloture($user, 4, '');
@ -425,7 +431,6 @@ else if ($action == 'setstatut' && $user->rights->propale->cloturer)
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'</div>';
$action='statut';
$action='statut';
}
else
{
@ -486,11 +491,11 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
if ($result > 0)
{
$objectref = dol_sanitizeFileName($object->ref);
$file = $conf->propale->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
// $objectref = dol_sanitizeFileName($object->ref);
// $file = $conf->propal->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
if (is_readable($file))
{
// if (is_readable($file))
// {
if ($_POST['sendto'])
{
// Le destinataire a ete fourni via le champ libre
@ -612,13 +617,13 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
dol_syslog('Recipient email is empty');
}
}
/* }
else
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dol_syslog('Failed to read file: '.$file);
}
}*/
}
else
{
@ -838,7 +843,7 @@ else if ($action == "addline" && $user->rights->propale->creer)
}
// Mise a jour d'une ligne dans la propale
if ($action == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save"))
else if ($action == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save"))
{
if (! $object->fetch($_POST["id"]) > 0)
{
@ -945,31 +950,31 @@ else if ($action == 'builddoc' && $user->rights->propale->creer)
}
// Set project
else if ($action == 'classin')
else if ($action == 'classin' && $user->rights->propale->creer)
{
$object->fetch($id);
$object->setProject($_POST['projectid']);
}
// Delai de livraison
else if ($action == 'setavailability')
else if ($action == 'setavailability' && $user->rights->propale->creer)
{
$object->fetch($id);
$result = $object->availability($_POST['availability_id']);
}
// Origine de la propale
else if ($action == 'setdemandreason')
else if ($action == 'setdemandreason' && $user->rights->propale->creer)
{
$object->fetch($id);
$result = $object->demand_reason($_POST['demand_reason_id']);
}
// Conditions de reglement
else if ($action == 'setconditions')
else if ($action == 'setconditions' && $user->rights->propale->creer)
{
$object->fetch($id);
$result = $object->cond_reglement($_POST['cond_reglement_id']);
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
}
else if ($action == 'setremisepercent' && $user->rights->propale->creer)
@ -985,10 +990,10 @@ else if ($action == 'setremiseabsolue' && $user->rights->propale->creer)
}
// Mode de reglement
else if ($action == 'setmode')
else if ($action == 'setmode' && $user->rights->propale->creer)
{
$object->fetch($id);
$result = $object->mode_reglement($_POST['mode_reglement_id']);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
}
/*
@ -1039,6 +1044,68 @@ else if ($action == 'down' && $user->rights->propale->creer)
exit;
}
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
if ($action == 'addcontact' && $user->rights->propale->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// Bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->propale->creer)
{
if ($object->fetch($id) > 0)
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->propale->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
dol_print_error($db);
}
}
}
/*
* View
@ -1062,8 +1129,6 @@ if ($id > 0 || ! empty($ref))
dol_htmloutput_mesg($mesg,$mesgs);
$object->fetch($id,$ref);
$soc = new Societe($db);
$soc->fetch($object->socid);
@ -1087,25 +1152,25 @@ if ($id > 0 || ! empty($ref))
}
// Confirm delete
if ($action == 'delete')
else if ($action == 'delete')
{
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp',$object->ref), 'confirm_delete','',0,1);
}
// Confirm reopen
if ($action == 'reopen')
else if ($action == 'reopen')
{
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp',$object->ref), 'confirm_reopen','',0,1);
}
// Confirmation delete product/service line
if ($action == 'ask_deleteline')
else if ($action == 'ask_deleteline')
{
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1);
}
// Confirm validate proposal
if ($action == 'validate')
else if ($action == 'validate')
{
$error=0;
@ -1180,8 +1245,6 @@ if ($id > 0 || ! empty($ref))
print '</td>';
print '</tr>';
$rowspan=11;
// Company
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$soc->getNomUrl(1).'</td>';
print '</tr>';
@ -1247,20 +1310,6 @@ if ($id > 0 || ! empty($ref))
}
print '</td>';
if ($conf->projet->enabled) $rowspan++;
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) $rowspan++;
//Local taxes
if ($mysoc->country_code=='ES')
{
if($mysoc->localtax1_assuj=="1") $rowspan++;
if($mysoc->localtax2_assuj=="1") $rowspan++;
}
// Notes
print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('NotePublic').' :<br>'. nl2br($object->note_public).'</td>';
print '</tr>';
// Date end proposal
print '<tr>';
print '<td>';
@ -1338,29 +1387,6 @@ if ($id > 0 || ! empty($ref))
print '</td>';
print '</tr>';
// Delivery address (deprecated)
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS)
{
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdelivery_address')
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','propal',$object->id);
}
else
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','propal',$object->id);
}
print '</td></tr>';
}
// Delivery delay
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
@ -1480,12 +1506,12 @@ if ($id > 0 || ! empty($ref))
// Amount HT
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2" nowrap><b>'.price($object->total_ht).'</b></td>';
print '<td align="right" nowrap><b>'.price($object->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
// Amount VAT
print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td>';
print '<td align="right" colspan="2" nowrap>'.price($object->total_tva).'</td>';
print '<td align="right" nowrap>'.price($object->total_tva).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
// Amount Local Taxes
@ -1494,26 +1520,44 @@ if ($id > 0 || ! empty($ref))
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{
print '<tr><td height="10">'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>';
print '<td align="right" colspan="2" nowrap>'.price($object->total_localtax1).'</td>';
print '<td align="right" nowrap>'.price($object->total_localtax1).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{
print '<tr><td height="10">'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>';
print '<td align="right" colspan="2" nowrap>'.price($object->total_localtax2).'</td>';
print '<td align="right" nowrap>'.price($object->total_localtax2).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
}
}
// Amount TTC
print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td>';
print '<td align="right" colspan="2" nowrap>'.price($object->total_ttc).'</td>';
print '<td align="right" nowrap>'.price($object->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
// Statut
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$object->getLibStatut(4).'</td></tr>';
print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*
* Lines
*/
@ -1626,16 +1670,11 @@ if ($id > 0 || ! empty($ref))
// Send
if ($object->statut == 1 || $object->statut == 2)
{
$propref = dol_sanitizeFileName($object->ref);
$file = $conf->propale->dir_output . '/'.$propref.'/'.$propref.'.pdf';
if (file_exists($file))
{
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propale->propal_advance->send)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
}
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
}
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propale->propal_advance->send)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
}
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
}
// Create an order
@ -1698,7 +1737,7 @@ if ($id > 0 || ! empty($ref))
* Documents generes
*/
$filename=dol_sanitizeFileName($object->ref);
$filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
$filedir=$conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed=$user->rights->propale->creer;
$delallowed=$user->rights->propale->supprimer;
@ -1731,7 +1770,33 @@ if ($id > 0 || ! empty($ref))
if ($action == 'presend')
{
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->propale->dir_output . '/' . $ref . '/' . $ref . '.pdf';
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref);
$file=$fileparams['fullname'];
// Build document if it not exists
if (! $file || ! is_readable($file))
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0)
{
dol_print_error($db,$result);
exit;
}
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref);
$file=$fileparams['fullname'];
}
print '<br>';
print_titre($langs->trans('SendPropalByMail'));
@ -1758,6 +1823,8 @@ if ($id > 0 || ! empty($ref))
// Tableau des substitutions
$formmail->substit['__PROPREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']='';
$formmail->substit['__PERSONALIZED__']='';
// Tableau des parametres complementaires
$formmail->param['action']='send';
$formmail->param['models']='propal_send';
@ -1765,10 +1832,10 @@ if ($id > 0 || ! empty($ref))
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
if (GETPOST("mode")=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,dol_sanitizeFilename($object->ref).'.pdf','application/pdf');
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
}
$formmail->show_form();
@ -1938,7 +2005,7 @@ else
print '<td width="16" align="right" class="nobordernopadding">';
$filename=dol_sanitizeFileName($objp->ref);
$filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($objp->ref);
$filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($objp->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->propalid;
$formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1);
print '</td></tr></table>';
@ -2013,7 +2080,7 @@ else
}
// End of page
llxFooter();
$db->close();
?>

View File

@ -119,7 +119,7 @@ if ($id > 0 || ! empty($ref))
* Documents
*/
$objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->propale->dir_output . "/";
$dir_output = $conf->propal->dir_output . "/";
$filepath = $dir_output . $objectref . "/";
$file = $filepath . $objectref . ".pdf";
$filedetail = $filepath . $objectref . "-detail.pdf";

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,7 @@ require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$langs->load("facture");
@ -34,15 +35,17 @@ $langs->load("orders");
$langs->load("sendings");
$langs->load("companies");
$id=GETPOST('id', 'int');
$ref= GETPOST('ref', 'alpha');
$lineid=GETPOST('lineid', 'int');
$action=GETPOST('action', 'alpha');
$id=GETPOST('id','int');
$ref= GETPOST('ref','alpha');
$lineid=GETPOST('lineid','int');
$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'propale', $id, 'propal');
$object = new Propal($db);
/*
* Ajout d'un nouveau contact
@ -50,42 +53,39 @@ $result = restrictedArea($user, 'propale', $id, 'propal');
if ($action == 'addcontact' && $user->rights->propale->creer)
{
$result = 0;
$propal = new Propal($db);
$result = $propal->fetch($id);
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
$result = $propal->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$propal->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($propal->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$propal->error.'</div>';
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// Bascule du statut d'un contact
if ($action == 'swapstatut' && $user->rights->propale->creer)
else if ($action == 'swapstatut' && $user->rights->propale->creer)
{
$propal = new Propal($db);
if ($propal->fetch($id) > 0)
if ($object->fetch($id) > 0)
{
$result=$propal->swapContactStatus(GETPOST('ligne'));
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
@ -94,15 +94,14 @@ if ($action == 'swapstatut' && $user->rights->propale->creer)
}
// Efface un contact
if ($action == 'deleteline' && $user->rights->propale->creer)
else if ($action == 'deletecontact' && $user->rights->propale->creer)
{
$propal = new Propal($db);
$propal->fetch($id);
$result = $propal->delete_contact($lineid);
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$propal->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
@ -111,6 +110,13 @@ if ($action == 'deleteline' && $user->rights->propale->creer)
}
}
else if ($action == 'setaddress' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->setDeliveryAddress($_POST['fk_address']);
if ($result < 0) dol_print_error($db,$object->error);
}
/*
* View
@ -120,8 +126,7 @@ llxHeader('', $langs->trans("Proposal"), "Propal");
$form = new Form($db);
$formcompany= new FormCompany($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);
$formother = new FormOther($db);
/* *************************************************************************** */
@ -133,13 +138,12 @@ dol_htmloutput_mesg($mesg);
if ($id > 0 || ! empty($ref))
{
$propal = New Propal($db);
if ($propal->fetch($id,$ref) > 0)
if ($object->fetch($id,$ref) > 0)
{
$soc = new Societe($db);
$soc->fetch($propal->socid);
$soc->fetch($object->socid);
$head = propal_prepare_head($propal);
$head = propal_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal');
/*
@ -151,7 +155,7 @@ if ($id > 0 || ! empty($ref))
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($propal,'ref',$linkback,1,'ref','ref','');
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>';
// Ref client
@ -161,202 +165,47 @@ if ($id > 0 || ! empty($ref))
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $propal->ref_client;
print $object->ref_client;
print '</td>';
print '</tr>';
// Customer
if ( is_null($propal->client) )
$propal->fetch_thirdparty();
if (is_null($object->client)) $object->fetch_thirdparty();
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$propal->client->getNomUrl(1).'</td></tr>';
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
// Delivery address
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
{
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdelivery_address')
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id);
}
else
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id);
}
print '</td></tr>';
}
print "</table>";
print '</div>';
/*
* Lignes de contacts
*/
print '<br><table class="noborder" width="100%">';
/*
* Ajouter une ligne de contact
* Non affiche en mode modification de ligne
*/
if ($action != 'editline' && $user->rights->propale->creer)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td colspan="3">&nbsp;</td>';
print "</tr>\n";
$var = false;
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="internal">';
// Line to add an internal contact
print "<tr ".$bc[$var].">";
print '<td nowrap="nowrap">';
print img_object('','user').' '.$langs->trans("Users");
print '</td>';
print '<td>';
print $conf->global->MAIN_INFO_SOCIETE_NOM;
print '</td>';
print '<td>';
// On recupere les id des users deja selectionnes
//$userAlreadySelected = $propal->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type
$form->select_users($user->id,'contactid',0,$userAlreadySelected);
print '</td>';
print '<td>';
$formcompany->selectTypeContact($propal, '', 'type','internal');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
print '</form>';
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="source" value="external">';
// Line to add an external contact
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td nowrap="nowrap">';
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
print '</td>';
print '<td>';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$propal->client->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($propal, 'id', $selectedCompany, 'newcompany');
print '</td>';
print '<td>';
$nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid');
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$formcompany->selectTypeContact($propal, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="disabled"';
print '></td>';
print '</tr>';
print '</form>';
print '<tr><td colspan="7">&nbsp;</td></tr>';
}
// Liste des contacts lies
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td align="center">'.$langs->trans("Status").'</td>';
print '<td colspan="2">&nbsp;</td>';
print "</tr>\n";
$companystatic = new Societe($db);
$var = true;
foreach(array('internal','external') as $source)
{
$tab = $propal->liste_contact(-1,$source);
$num=count($tab);
$i = 0;
while ($i < $num)
{
$var = !$var;
print '<tr '.$bc[$var].' valign="top">';
// Source
print '<td align="left">';
if ($tab[$i]['source']=='internal') print $langs->trans("User");
if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact");
print '</td>';
// Societe
print '<td align="left">';
if ($tab[$i]['socid'] > 0)
{
$companystatic->fetch($tab[$i]['socid']);
print $companystatic->getNomUrl(1);
}
if ($tab[$i]['socid'] < 0)
{
print $conf->global->MAIN_INFO_SOCIETE_NOM;
}
if (! $tab[$i]['socid'])
{
print '&nbsp;';
}
print '</td>';
// Contact
print '<td>';
if ($tab[$i]['source']=='internal')
{
$userstatic->id=$tab[$i]['id'];
$userstatic->lastname=$tab[$i]['lastname'];
$userstatic->firstname=$tab[$i]['firstname'];
print $userstatic->getNomUrl(1);
}
if ($tab[$i]['source']=='external')
{
$contactstatic->id=$tab[$i]['id'];
$contactstatic->lastname=$tab[$i]['lastname'];
$contactstatic->firstname=$tab[$i]['firstname'];
print $contactstatic->getNomUrl(1);
}
print '</td>';
// Type de contact
print '<td>'.$tab[$i]['libelle'].'</td>';
// Statut
print '<td align="center">';
// Activation desativation du contact
if ($propal->statut >= 0) print '<a href="contact.php?id='.$propal->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print $contactstatic->LibStatut($tab[$i]['status'],3);
if ($propal->statut >= 0) print '</a>';
print '</td>';
// Icon update et delete
print '<td align="center" nowrap="nowrap" colspan="2">';
if ($user->rights->propale->creer)
{
print '&nbsp;';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'&amp;action=deleteline&amp;lineid='.$tab[$i]['rowid'].'">';
print img_delete();
print '</a>';
}
print '</td>';
print "</tr>\n";
$i ++;
}
}
print "</table>";
print '<br>';
// Contacts lines
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
}
else
{
@ -364,8 +213,6 @@ if ($id > 0 || ! empty($ref))
}
}
llxFooter();
$db->close();
llxFooter();
?>

View File

@ -70,7 +70,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$object->fetch_thirdparty();
$upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
if (dol_mkdir($upload_dir) >= 0)
{
@ -106,7 +106,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
$object->fetch_thirdparty();
$upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
@ -128,7 +128,7 @@ if ($id > 0 || ! empty($ref))
{
$object->fetch_thirdparty();
$upload_dir = $conf->propale->dir_output.'/'.dol_sanitizeFileName($object->ref);
$upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
$head = propal_prepare_head($object);
dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');

View File

@ -248,7 +248,7 @@ if ($resql)
print '<td width="16" align="right" class="nobordernopadding">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
$formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1);
print '</td></tr></table>';
@ -318,7 +318,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire)
print '</td>';
print '<td width="16" align="center" class="nobordernopadding">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
$formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1);
print '</td></tr></table>';

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -32,57 +32,35 @@ $langs->load('propal');
$langs->load('compta');
$langs->load('bills');
$id = isset($_GET["id"])?$_GET["id"]:'';
$id = GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'propale', $id, 'propal');
$object = new Propal($db);
/******************************************************************************/
/* Actions */
/******************************************************************************/
if ($_POST["action"] == 'update_public' && $user->rights->propale->creer)
{
$propal = new Propal($db);
$propal->fetch($_GET["id"]);
$db->begin();
$res=$propal->update_note_public($_POST["note_public"],$user);
if ($res < 0)
{
$mesg='<div class="error">'.$propal->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
if ($action == 'setnote_public' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->propale->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
if ($_POST['action'] == 'update' && $user->rights->propale->creer)
{
$propal = new Propal($db);
$propal->fetch($_GET["id"]);
$db->begin();
$res=$propal->update_note($_POST["note"],$user);
if ($res < 0)
{
$mesg='<div class="error">'.$propal->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
}
/******************************************************************************/
/* Affichage fiche */
@ -92,21 +70,18 @@ llxHeader();
$form = new Form($db);
$id = $_GET["id"];
$ref= $_GET["ref"];
if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg;
$now=gmmktime();
$propal = new Propal($db);
if ($propal->fetch($id, $ref))
if ($object->fetch($id, $ref))
{
$societe = new Societe($db);
if ( $societe->fetch($propal->socid) )
if ( $societe->fetch($object->socid) )
{
$head = propal_prepare_head($propal);
$head = propal_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal');
print '<table class="border" width="100%">';
@ -115,7 +90,7 @@ if ($id > 0 || ! empty($ref))
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($propal,'ref',$linkback,1,'ref','ref','');
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>';
// Ref client
@ -125,15 +100,15 @@ if ($id > 0 || ! empty($ref))
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $propal->ref_client;
print $object->ref_client;
print '</td>';
print '</tr>';
// Customer
if ( is_null($propal->client) )
$propal->fetch_thirdparty();
if ( is_null($object->client) )
$object->fetch_thirdparty();
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$propal->client->getNomUrl(1).'</td></tr>';
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
// Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
@ -148,17 +123,17 @@ if ($id > 0 || ! empty($ref))
// Date
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
print dol_print_date($propal->date,'daytext');
print dol_print_date($object->date,'daytext');
print '</td>';
print '</tr>';
// Date fin propal
print '<tr>';
print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">';
if ($propal->fin_validite)
if ($object->fin_validite)
{
print dol_print_date($propal->fin_validite,'daytext');
if ($propal->statut == 1 && $propal->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
print dol_print_date($object->fin_validite,'daytext');
if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
}
else
{
@ -167,63 +142,18 @@ if ($id > 0 || ! empty($ref))
print '</td>';
print '</tr>';
// Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?id='.$propal->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_public">';
print '<textarea name="note_public" cols="80" rows="8">'.$propal->note_public."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($propal->note_public?nl2br($propal->note_public):"&nbsp;");
}
print "</td></tr>";
// Note privee
if (! $user->societe_id)
{
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?id='.$propal->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<textarea name="note" cols="80" rows="8">'.$propal->note."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($propal->note?nl2br($propal->note):"&nbsp;");
}
print "</td></tr>";
}
print "</table>";
print '</div>';
print '<br>';
/*
* Actions
*/
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
print '<div class="tabsAction">';
if ($user->rights->propale->creer && $_GET['action'] <> 'edit')
{
print '<a class="butAction" href="note.php?id='.$propal->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
}
print '</div>';
dol_fiche_end();
}
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -58,7 +58,7 @@ llxHeader();
print_fiche_titre($langs->trans("ProposalsStatistics"), $mesg);
$dir=$conf->propale->dir_temp;
$dir=$conf->propal->dir_temp;
dol_mkdir($dir);

View File

@ -27,7 +27,7 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
echo '<br>';
print_titre($langs->trans('RelatedCommercialProposals'));
?>
<table class="noborder" width="100%">
<table class="noborder allwidth">
<tr class="liste_titre">
<td><?php echo $langs->trans("Ref"); ?></td>
<td><?php echo $langs->trans('RefCustomer'); ?></td>

View File

@ -50,8 +50,9 @@ class Prospect extends Societe
/**
* \brief Charge indicateurs this->nb de tableau de bord
* \return int <0 if KO, >0 if OK
* Charge indicateurs this->nb de tableau de bord
*
* @return int <0 if KO, >0 if OK
*/
function load_state_board()
{
@ -92,9 +93,10 @@ class Prospect extends Societe
/**
* \brief Return status of prospect
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* \return string Libelle
* Return status of prospect
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* @return string Libelle
*/
function getLibProspStatut($mode=0)
{
@ -102,10 +104,11 @@ class Prospect extends Societe
}
/**
* \brief Return label of a given status
* \param statut Id statut
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* \return string Libelle du statut
* Return label of a given status
*
* @param int $statut Id statut
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Libelle du statut
*/
function LibProspStatut($statut,$mode=0)
{
@ -141,8 +144,9 @@ class Prospect extends Societe
}
/**
* \brief Renvoi le libelle du niveau
* \return string Libelle
* Renvoi le libelle du niveau
*
* @return string Libelle
*/
function getLibLevel()
{
@ -150,9 +154,10 @@ class Prospect extends Societe
}
/**
* \brief Renvoi le libelle du niveau
* \param fk_prospectlevel Prospect level
* \return string Libelle du niveau
* Renvoi le libelle du niveau
*
* @param int $fk_prospectlevel Prospect level
* @return string Libelle du niveau
*/
function LibLevel($fk_prospectlevel)
{

View File

@ -312,8 +312,6 @@ if ($socid > 0)
}
}
//print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$societe->id.'&amp;action=create">'.$langs->trans("AddContact").'</a>';
print '</div>';
print '<br>';

View File

@ -83,6 +83,10 @@ class Commande extends CommonObject
var $rang;
var $special_code;
var $source; // Origin of order
var $note; // deprecated
var $note_private;
var $note_public;
var $extraparams=array();
var $origin;
var $origin_id;
@ -506,6 +510,7 @@ class Commande extends CommonObject
* Cancel an order
* If stock is decremented on order validation, we must reincrement it
*
* @param User $user Object user
* @param int $idwarehouse Id warehouse to use for stock change.
* @return int <0 if KO, >0 if OK
*/
@ -584,7 +589,7 @@ class Commande extends CommonObject
* Note that this->ref can be set or empty. If empty, we will use "(PROV)"
*
* @param User $user Objet user that make creation
* @param int notrigger Disable all triggers
* @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/
function create($user, $notrigger=0)
@ -667,25 +672,25 @@ class Commande extends CommonObject
}
$result = $this->addline(
$this->id,
$this->lines[$i]->desc,
$this->lines[$i]->subprice,
$this->lines[$i]->qty,
$this->lines[$i]->tva_tx,
$this->lines[$i]->localtax1_tx,
$this->lines[$i]->localtax2_tx,
$this->lines[$i]->fk_product,
$this->lines[$i]->remise_percent,
$this->lines[$i]->info_bits,
$this->lines[$i]->fk_remise_except,
'HT',
0,
$this->lines[$i]->date_start,
$this->lines[$i]->date_end,
$this->lines[$i]->product_type,
$this->lines[$i]->rang,
$this->lines[$i]->special_code,
$fk_parent_line
$this->id,
$this->lines[$i]->desc,
$this->lines[$i]->subprice,
$this->lines[$i]->qty,
$this->lines[$i]->tva_tx,
$this->lines[$i]->localtax1_tx,
$this->lines[$i]->localtax2_tx,
$this->lines[$i]->fk_product,
$this->lines[$i]->remise_percent,
$this->lines[$i]->info_bits,
$this->lines[$i]->fk_remise_except,
'HT',
0,
$this->lines[$i]->date_start,
$this->lines[$i]->date_end,
$this->lines[$i]->product_type,
$this->lines[$i]->rang,
$this->lines[$i]->special_code,
$fk_parent_line
);
if ($result < 0)
{
@ -707,7 +712,7 @@ class Commande extends CommonObject
if ($this->id)
{
$this->ref="(PROV".$this->id.")";
// Add object linked
if (is_array($this->linked_objects) && ! empty($this->linked_objects))
{
@ -719,25 +724,25 @@ class Commande extends CommonObject
dol_print_error($this->db);
$error++;
}
// TODO mutualiser
if ($origin == 'propal' && $origin_id)
{
// On recupere les differents contact interne et externe
$prop = new Propal($this->db, $this->socid, $origin_id);
// On recupere le commercial suivi propale
$this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
if ($this->userid)
{
//On passe le commercial suivi propale en commercial suivi commande
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
}
// On recupere le contact client suivi propale
$this->contactid = $prop->getIdcontact('external', 'CUSTOMER');
if ($this->contactid)
{
//On passe le contact client suivi propale en contact client suivi commande
@ -868,6 +873,7 @@ class Commande extends CommonObject
function createFromProposal($object)
{
global $conf,$user,$langs;
global $hookmanager;
$error=0;
@ -915,16 +921,26 @@ class Commande extends CommonObject
$this->note = $object->note;
$this->note_public = $object->note_public;
$this->origin = $object->element;
$this->origin_id = $object->id;
$this->origin = $object->element;
$this->origin_id = $object->id;
// 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))
{
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user);
if ($ret > 0)
{
// Actions hooked (by external module)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
if (! is_object($hookmanager))
{
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('orderdao'));
$parameters=array('objFrom'=>$object);
@ -970,6 +986,8 @@ class Commande extends CommonObject
* @param timestamp $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
* @param int $type Type of line (0=product, 1=service)
* @param int $rang Position of line
* @param int $special_code Special code
* @param int $fk_parent_line Parent line
* @return int >0 if OK, <0 if KO
*
* @see add_product
@ -1210,7 +1228,7 @@ class Commande extends CommonObject
$sql.= ', c.date_commande';
$sql.= ', c.date_livraison';
$sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as facturee';
$sql.= ', c.note, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison';
$sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison, c.extraparams';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
$sql.= ', ca.code as availability_code';
@ -1255,7 +1273,8 @@ class Commande extends CommonObject
$this->remise_absolue = $obj->remise_absolue;
$this->source = $obj->source;
$this->facturee = $obj->facturee;
$this->note = $obj->note;
$this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->fk_project = $obj->fk_projet;
$this->modelpdf = $obj->model_pdf;
@ -1274,6 +1293,8 @@ class Commande extends CommonObject
$this->fk_delivery_address = $obj->fk_adresse_livraison;
$this->propale_id = $obj->fk_source;
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->lines = array();
if ($this->statut == 0) $this->brouillon = 1;
@ -1553,6 +1574,8 @@ class Commande extends CommonObject
/**
* Returns a array with expeditions lines number
*
* @return int Nb of shipments
*
* TODO deprecated, move to Shipping class
*/
function nb_expedition()
@ -1844,34 +1867,6 @@ class Commande extends CommonObject
}
}
/**
* Set address
*
* @param User $user Object user making change
* @param int $fk_address Adress of delivery
* @return int <0 ig KO, >0 if Ok
*/
function set_adresse_livraison($user, $fk_address)
{
if ($user->rights->commande->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_adresse_livraison = '".$fk_address."'";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
if ($this->db->query($sql) )
{
$this->fk_delivery_address = $fk_address;
return 1;
}
else
{
$this->error=$this->db->error();
dol_syslog("Commande::set_adresse_livraison Erreur SQL");
return -1;
}
}
}
/**
* Set availability
*
@ -1975,75 +1970,6 @@ class Commande extends CommonObject
}
}
/**
* Change les conditions de reglement de la commande
*
* @param int $cond_reglement_id Id de la nouvelle condition de reglement
* @return int >0 if OK, <0 if KO
*/
function cond_reglement($cond_reglement_id)
{
dol_syslog('Commande::cond_reglement('.$cond_reglement_id.')');
if ($this->statut >= 0)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_cond_reglement = '.$cond_reglement_id;
$sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
{
$this->cond_reglement_id = $cond_reglement_id;
return 1;
}
else
{
dol_syslog('Commande::cond_reglement Erreur '.$sql.' - '.$this->db->error(), LOG_ERR);
$this->error=$this->db->lasterror();
return -1;
}
}
else
{
dol_syslog('Commande::cond_reglement, etat commande incompatible', LOG_ERR);
$this->error='Etat commande incompatible '.$this->statut;
return -2;
}
}
/**
* Change le mode de reglement
*
* @param int $mode Id du nouveau mode
* @return int >0 si ok, <0 si ko
*/
function mode_reglement($mode_reglement_id)
{
dol_syslog('Commande::mode_reglement('.$mode_reglement_id.')');
if ($this->statut >= 0)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_mode_reglement = '.$mode_reglement_id;
$sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
{
$this->mode_reglement_id = $mode_reglement_id;
return 1;
}
else
{
dol_syslog('Commande::mode_reglement Erreur '.$sql.' - '.$this->db->error(), LOG_ERR);
$this->error=$this->db->lasterror();
return -1;
}
}
else
{
dol_syslog('Commande::mode_reglement, etat facture incompatible', LOG_ERR);
$this->error='Etat commande incompatible '.$this->statut;
return -2;
}
}
/**
* Change le delai de livraison
*
@ -2114,6 +2040,7 @@ class Commande extends CommonObject
/**
* Set customer ref
*
* @param User $user User that make change
* @param string $ref_client Customer ref
* @return int <0 if KO, >0 if OK
@ -2184,7 +2111,7 @@ class Commande extends CommonObject
* @param double $pu Prix unitaire
* @param double $qty Quantity
* @param double $remise_percent Pourcentage de remise de la ligne
* @param double $tva_tx Taux TVA
* @param double $txtva Taux TVA
* @param double $txlocaltax1 Local tax 1 rate
* @param double $txlocaltax2 Local tax 2 rate
* @param string $price_base_type HT or TTC
@ -2192,6 +2119,8 @@ class Commande extends CommonObject
* @param timestamp $date_start Start date of the line
* @param timestamp $date_end End date of the line
* @param int $type Type of line (0=product, 1=service)
* @param int $fk_parent_line Parent line id
* @param int $skip_update_total Skip update of total
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0)
@ -2323,7 +2252,7 @@ class Commande extends CommonObject
$error = 0;
$this->db->begin();
if (! $error && ! $notrigger)
{
// Appel des triggers
@ -2335,7 +2264,7 @@ class Commande extends CommonObject
}
// Fin appel triggers
}
if (! $error)
{
// Delete order details
@ -2346,7 +2275,7 @@ class Commande extends CommonObject
dol_syslog(get_class($this)."::delete error", LOG_ERR);
$error++;
}
// Delete order
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
@ -2355,15 +2284,15 @@ class Commande extends CommonObject
dol_syslog(get_class($this)."::delete error", LOG_ERR);
$error++;
}
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0) $error++;
// On efface le repertoire de pdf provisoire
$comref = dol_sanitizeFileName($this->ref);
if ($conf->commande->dir_output)
@ -2373,7 +2302,7 @@ class Commande extends CommonObject
if (file_exists($file)) // We must delete all files before deleting directory
{
dol_delete_preview($this);
if (!dol_delete_file($file))
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
@ -2392,7 +2321,7 @@ class Commande extends CommonObject
}
}
}
if (! $error)
{
dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG);
@ -2500,7 +2429,7 @@ class Commande extends CommonObject
if ($statut==3 && ! $facturee) return $langs->trans('StatusOrderToBill');
if ($statut==3 && $facturee) return $langs->trans('StatusOrderProcessed');
}
if ($mode == 1)
elseif ($mode == 1)
{
if ($statut==-1) return $langs->trans('StatusOrderCanceledShort');
if ($statut==0) return $langs->trans('StatusOrderDraftShort');
@ -2509,7 +2438,7 @@ class Commande extends CommonObject
if ($statut==3 && ! $facturee) return $langs->trans('StatusOrderToBillShort');
if ($statut==3 && $facturee) return $langs->trans('StatusOrderProcessed');
}
if ($mode == 2)
elseif ($mode == 2)
{
if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort');
if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort');
@ -2518,7 +2447,7 @@ class Commande extends CommonObject
if ($statut==3 && ! $facturee) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBillShort');
if ($statut==3 && $facturee) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessedShort');
}
if ($mode == 3)
elseif ($mode == 3)
{
if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
@ -2527,7 +2456,7 @@ class Commande extends CommonObject
if ($statut==3 && ! $facturee) return img_picto($langs->trans('StatusOrderToBill'),'statut7');
if ($statut==3 && $facturee) return img_picto($langs->trans('StatusOrderProcessed'),'statut6');
}
if ($mode == 4)
elseif ($mode == 4)
{
if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled');
if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft');
@ -2536,7 +2465,7 @@ class Commande extends CommonObject
if ($statut==3 && ! $facturee) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBill');
if ($statut==3 && $facturee) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessed');
}
if ($mode == 5)
elseif ($mode == 5)
{
if ($statut==-1) return $langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
if ($statut==0) return $langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
@ -2584,7 +2513,8 @@ class Commande extends CommonObject
/**
* Charge les informations d'ordre info dans l'objet commande
*
* @param int $id Id of order
* @param int $id Id of order
* @return void
*/
function info($id)
{
@ -2899,7 +2829,8 @@ class OrderLine
/**
* Load line order
*
* @param rowid id line order
* @param int $rowid Id line order
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid)
{

View File

@ -51,11 +51,11 @@ class CommandeStats extends Stats
* @param string $mode Option
* @param int $userid Id user for filter
*/
function CommandeStats($DB, $socid=0, $mode, $userid=0)
function CommandeStats($db, $socid, $mode, $userid=0)
{
global $user, $conf;
$this->db = $DB;
$this->db = $db;
$this->socid = $socid;
$this->userid = $userid;
@ -88,7 +88,7 @@ class CommandeStats extends Stats
/**
* Return orders number by month for a year
*
*
* @param int $year year for stats
* @return array array with number by month
*/
@ -110,7 +110,7 @@ class CommandeStats extends Stats
/**
* Return orders number by year
*
*
* @return array array with number by year
*
*/
@ -175,7 +175,7 @@ class CommandeStats extends Stats
/**
* Return nb, total and average
*
*
* @return array Array of values
*/
function getAllByYear()

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -27,61 +27,62 @@ require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/order.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$langs->load("orders");
$langs->load("sendings");
$langs->load("companies");
$comid = isset($_GET["id"])?$_GET["id"]:'';
$id=GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande', $comid,'');
$result = restrictedArea($user, 'commande', $id,'');
$object = new Commande($db);
/*
* Ajout d'un nouveau contact
*/
if ($_POST["action"] == 'addcontact' && $user->rights->commande->creer)
if ($action == 'addcontact' && $user->rights->commande->creer)
{
$result = $object->fetch($id);
$result = 0;
$commande = new Commande($db);
$result = $commande->fetch($_GET["id"]);
if ($result > 0 && $_GET["id"] > 0)
if ($result > 0 && $id > 0)
{
$result = $commande->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: contact.php?id=".$commande->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($commande->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$commande->error.'</div>';
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer)
else if ($action == 'swapstatut' && $user->rights->commande->creer)
{
$commande = new Commande($db);
if ($commande->fetch(GETPOST('id','int')))
if ($object->fetch($id))
{
$result=$commande->swapContactStatus(GETPOST('ligne'));
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
@ -90,15 +91,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer)
}
// Efface un contact
if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer)
else if ($action == 'deletecontact' && $user->rights->commande->creer)
{
$commande = new Commande($db);
$commande->fetch($_GET["id"]);
$result = $commande->delete_contact($_GET["lineid"]);
$object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0)
{
Header("Location: contact.php?id=".$commande->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
@ -106,6 +106,11 @@ if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer)
}
}
else if ($action == 'setaddress' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->setDeliveryAddress($_POST['fk_address']);
}
/*
* View
@ -115,6 +120,7 @@ llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES
$form = new Form($db);
$formcompany = new FormCompany($db);
$formother = new FormOther($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);
@ -126,19 +132,17 @@ $userstatic=new User($db);
/* *************************************************************************** */
dol_htmloutput_mesg($mesg);
$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
$langs->trans("OrderCard");
$commande = new Commande($db);
if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0)
if ($object->fetch($id, $ref) > 0)
{
$soc = new Societe($db);
$soc->fetch($commande->socid);
$soc->fetch($object->socid);
$head = commande_prepare_head($commande);
$head = commande_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), 0, 'order');
@ -149,7 +153,7 @@ if ($id > 0 || ! empty($ref))
// Ref
print '<tr><td width="18%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($commande,'ref','',1,'ref','ref');
print $form->showrefnav($object,'ref','',1,'ref','ref');
print "</td></tr>";
// Ref commande client
@ -159,201 +163,48 @@ if ($id > 0 || ! empty($ref))
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $commande->ref_client;
print $object->ref_client;
print '</td>';
print '</tr>';
// Customer
if ( is_null($commande->client) )
$commande->fetch_thirdparty();
if (is_null($object->client)) $object->fetch_thirdparty();
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$commande->client->getNomUrl(1).'</td></tr>';
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
// Delivery address
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
{
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdelivery_address')
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id);
}
else
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id);
}
print '</td></tr>';
}
print "</table>";
print '</div>';
/*
* Lignes de contacts
*/
echo '<br><table class="noborder" width="100%">';
print '<br>';
// Contacts lines
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
/*
* Ajouter une ligne de contact
* Non affiche en mode modification de ligne
*/
if ($_GET["action"] != 'editline' && $user->rights->commande->creer)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td>&nbsp;</td>';
print '<td colspan="2">&nbsp;</td>';
print "</tr>\n";
$var = false;
print '<form action="contact.php?id='.$id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="internal">';
print '<input type="hidden" name="id" value="'.$id.'">';
// Ligne ajout pour contact interne
print '<tr '.$bc[$var].'>';
print '<td nowrap="nowrap">';
print img_object('','user').' '.$langs->trans("Users");
print '</td>';
print '<td colspan="1">';
print $conf->global->MAIN_INFO_SOCIETE_NOM;
print '</td>';
print '<td colspan="1">';
//$userAlreadySelected = $commande->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type
$form->select_users($user->id,'contactid',0,$userAlreadySelected);
print '</td>';
print '<td>';
$formcompany->selectTypeContact($commande, '', 'type','internal');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
print '</form>';
print '<form action="contact.php?id='.$id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="external">';
print '<input type="hidden" name="id" value="'.$id.'">';
// Ligne ajout pour contact externe
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td nowrap="nowrap">';
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
print '</td>';
print '<td colspan="1">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$commande->client->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($commande, 'id', $selectedCompany, 'newcompany');
print '</td>';
print '<td colspan="1">';
$nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid');
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$formcompany->selectTypeContact($commande, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="disabled"';
print '></td>';
print '</tr>';
print "</form>";
print '<tr><td colspan="7">&nbsp;</td></tr>';
}
// List of linked contacts
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td align="center">'.$langs->trans("Status").'</td>';
print '<td colspan="2">&nbsp;</td>';
print "</tr>\n";
$companystatic=new Societe($db);
$var = true;
foreach(array('internal','external') as $source)
{
$tab = $commande->liste_contact(-1,$source);
$num=count($tab);
$i = 0;
while ($i < $num)
{
$var = !$var;
print '<tr '.$bc[$var].' valign="top">';
// Source
print '<td align="left">';
if ($tab[$i]['source']=='internal') print $langs->trans("User");
if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact");
print '</td>';
// Societe
print '<td align="left">';
if ($tab[$i]['socid'] > 0)
{
$companystatic->fetch($tab[$i]['socid']);
print $companystatic->getNomUrl(1);
}
if ($tab[$i]['socid'] < 0)
{
print $conf->global->MAIN_INFO_SOCIETE_NOM;
}
if (! $tab[$i]['socid'])
{
print '&nbsp;';
}
print '</td>';
// Contact
print '<td>';
if ($tab[$i]['source']=='internal')
{
$userstatic->id=$tab[$i]['id'];
$userstatic->lastname=$tab[$i]['lastname'];
$userstatic->firstname=$tab[$i]['firstname'];
print $userstatic->getNomUrl(1);
}
if ($tab[$i]['source']=='external')
{
$contactstatic->id=$tab[$i]['id'];
$contactstatic->lastname=$tab[$i]['lastname'];
$contactstatic->firstname=$tab[$i]['firstname'];
print $contactstatic->getNomUrl(1);
}
print '</td>';
// Type de contact
print '<td>'.$tab[$i]['libelle'].'</td>';
// Statut
print '<td align="center">';
// Activation desativation du contact
if ($commande->statut >= 0) print '<a href="contact.php?id='.$commande->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print $contactstatic->LibStatut($tab[$i]['status'],3);
if ($commande->statut >= 0) print '</a>';
print '</td>';
// Icon update et delete
print '<td align="center" nowrap="nowrap" colspan="2">';
if ($commande->statut < 5 && $user->rights->commande->creer)
{
print '&nbsp;';
print '<a href="contact.php?id='.$commande->id.'&amp;action=deleteline&amp;lineid='.$tab[$i]['rowid'].'">';
print img_delete();
print '</a>';
}
print '</td>';
print "</tr>\n";
$i ++;
}
}
print "</table>";
}
else
{
@ -362,7 +213,7 @@ if ($id > 0 || ! empty($ref))
}
}
$db->close();
$db->close();
llxFooter();
?>

View File

@ -189,7 +189,8 @@ else
Header('Location: index.php');
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -29,7 +29,6 @@
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formorder.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/modules/commande/modules_commande.php");
@ -105,7 +104,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
}
// Reopen a closed order
if ($action == 'reopen' && $user->rights->commande->creer)
else if ($action == 'reopen' && $user->rights->commande->creer)
{
$object->fetch($id);
if ($object->statut == 3)
@ -124,7 +123,7 @@ if ($action == 'reopen' && $user->rights->commande->creer)
}
// Suppression de la commande
if ($action == 'confirm_delete' && $confirm == 'yes')
else if ($action == 'confirm_delete' && $confirm == 'yes')
{
if ($user->rights->commande->supprimer)
{
@ -143,7 +142,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes')
}
// Remove a product line
if ($action == 'confirm_deleteline' && $confirm == 'yes')
else if ($action == 'confirm_deleteline' && $confirm == 'yes')
{
if ($user->rights->commande->creer)
{
@ -179,14 +178,14 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes')
}
// Categorisation dans projet
if ($action == 'classin')
else if ($action == 'classin')
{
$object->fetch($id);
$object->setProject($_POST['projectid']);
}
// Add order
if ($action == 'add' && $user->rights->commande->creer)
else if ($action == 'add' && $user->rights->commande->creer)
{
$datecommande = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$datelivraison = dol_mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']);
@ -379,26 +378,26 @@ if ($action == 'add' && $user->rights->commande->creer)
}
if ($action == 'classifybilled')
else if ($action == 'classifybilled')
{
$object->fetch($id);
$object->classer_facturee();
}
// Positionne ref commande client
if ($action == 'set_ref_client' && $user->rights->commande->creer)
else if ($action == 'set_ref_client' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->set_ref_client($user, $_POST['ref_client']);
}
if ($action == 'setremise' && $user->rights->commande->creer)
else if ($action == 'setremise' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->set_remise($user, $_POST['remise']);
}
if ($action == 'setabsolutediscount' && $user->rights->commande->creer)
else if ($action == 'setabsolutediscount' && $user->rights->commande->creer)
{
if ($_POST["remise_id"])
{
@ -414,7 +413,7 @@ if ($action == 'setabsolutediscount' && $user->rights->commande->creer)
}
}
if ($action == 'setdate' && $user->rights->commande->creer)
else if ($action == 'setdate' && $user->rights->commande->creer)
{
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$date=dol_mktime(0, 0, 0, $_POST['order_month'], $_POST['order_day'], $_POST['order_year']);
@ -427,7 +426,7 @@ if ($action == 'setdate' && $user->rights->commande->creer)
}
}
if ($action == 'setdate_livraison' && $user->rights->commande->creer)
else if ($action == 'setdate_livraison' && $user->rights->commande->creer)
{
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$datelivraison=dol_mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
@ -440,56 +439,64 @@ if ($action == 'setdate_livraison' && $user->rights->commande->creer)
}
}
if ($action == 'setaddress' && $user->rights->commande->creer)
else if ($action == 'setmode' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->set_adresse_livraison($user,$_POST['fk_address']);
}
if ($action == 'setmode' && $user->rights->commande->creer)
{
$object->fetch($id);
$result=$object->mode_reglement($_POST['mode_reglement_id']);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setavailability' && $user->rights->commande->creer)
else if ($action == 'setavailability' && $user->rights->commande->creer)
{
$object->fetch($id);
$result=$object->availability($_POST['availability_id']);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setdemandreason' && $user->rights->commande->creer)
else if ($action == 'setdemandreason' && $user->rights->commande->creer)
{
$object->fetch($id);
$result=$object->demand_reason($_POST['demand_reason_id']);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setconditions' && $user->rights->commande->creer)
else if ($action == 'setconditions' && $user->rights->commande->creer)
{
$object->fetch($id);
$result=$object->cond_reglement($_POST['cond_reglement_id']);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setremisepercent' && $user->rights->facture->creer)
else if ($action == 'setremisepercent' && $user->rights->commande->creer)
{
$object->fetch($id);
$result = $object->set_remise($user, $_POST['remise_percent']);
}
if ($action == 'setremiseabsolue' && $user->rights->facture->creer)
else if ($action == 'setremiseabsolue' && $user->rights->commande->creer)
{
$object->fetch($id);
$result = $object->set_remise_absolue($user, $_POST['remise_absolue']);
}
else if ($action == 'setnote_public' && $user->rights->commande->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->commande->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
/*
* Ajout d'une ligne produit dans la commande
*/
if ($action == 'addline' && $user->rights->commande->creer)
else if ($action == 'addline' && $user->rights->commande->creer)
{
$result=0;
@ -674,7 +681,7 @@ if ($action == 'addline' && $user->rights->commande->creer)
/*
* Mise a jour d'une ligne dans la commande
*/
if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save'))
else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save'))
{
if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty();
@ -774,13 +781,13 @@ if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save']
}
}
if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel'))
else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel'))
{
Header('Location: fiche.php?id='.$id); // Pour reaffichage de la fiche en cours d'edition
exit;
}
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider)
else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider)
{
$idwarehouse=GETPOST('idwarehouse');
@ -819,7 +826,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->command
}
// Go back to draft status
if ($action == 'confirm_modif' && $user->rights->commande->creer)
else if ($action == 'confirm_modif' && $user->rights->commande->creer)
{
$idwarehouse=GETPOST('idwarehouse');
@ -861,7 +868,7 @@ if ($action == 'confirm_modif' && $user->rights->commande->creer)
}
}
if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer)
else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer)
{
$object->fetch($id); // Load order and lines
@ -869,7 +876,7 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->
if ($result < 0) $mesgs=$object->errors;
}
if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider)
else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider)
{
$idwarehouse=GETPOST('idwarehouse');
@ -898,7 +905,7 @@ if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande-
* Ordonnancement des lignes
*/
if ($action == 'up' && $user->rights->commande->creer)
else if ($action == 'up' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
@ -921,7 +928,7 @@ if ($action == 'up' && $user->rights->commande->creer)
exit;
}
if ($action == 'down' && $user->rights->commande->creer)
else if ($action == 'down' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
@ -943,7 +950,7 @@ if ($action == 'down' && $user->rights->commande->creer)
exit;
}
if ($action == 'builddoc') // In get or post
else if ($action == 'builddoc') // In get or post
{
/*
* Generate order document
@ -983,7 +990,7 @@ if ($action == 'builddoc') // In get or post
}
// Remove file in doc form
if ($action == 'remove_file')
else if ($action == 'remove_file')
{
if ($object->fetch($id))
{
@ -1041,11 +1048,11 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
if ($result > 0)
{
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
// $ref = dol_sanitizeFileName($object->ref);
// $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (is_readable($file))
{
// if (is_readable($file))
// {
if ($_POST['sendto'])
{
// Le destinataire a ete fourni via le champ libre
@ -1160,14 +1167,14 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
$mesg.='</div>';
}
}
}
/* }
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
$action='presend';
dol_syslog('Recipient email is empty');
}
}*/
}
else
{
@ -1184,6 +1191,67 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
}
}
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
if ($action == 'addcontact' && $user->rights->commande->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->commande->creer)
{
if ($object->fetch($id))
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->commande->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
dol_print_error($db);
}
}
}
/*
* View
@ -1193,7 +1261,6 @@ llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES
$form = new Form($db);
$formfile = new FormFile($db);
$formother = new FormOther($db);
$formorder = new FormOrder($db);
@ -1244,13 +1311,16 @@ if ($action == 'create' && $user->rights->commande->creer)
$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:'');
$soc = $objectsrc->client;
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
$availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0));
$demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0));
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
$availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0));
$demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0));
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
$note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : ''));
$note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : '');
// Object source contacts list
$srccontactslist = $objectsrc->liste_contact(-1,'external',1);
@ -1330,15 +1400,6 @@ if ($action == 'create' && $user->rights->commande->creer)
$form->select_date($datedelivery,'liv_','','','',"crea_commande",1,1);
print "</td></tr>";
// Delivery address
if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS)
{
print '<tr><td nowrap="nowrap">'.$langs->trans('DeliveryAddress').'</td><td colspan="2">';
$numaddress = $formother->select_address($soc->fk_delivery_address, $socid,'fk_address',1);
print ' &nbsp; <a href="../comm/address.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddAddress").'</a>';
print '</td></tr>';
}
// Conditions de reglement
print '<tr><td nowrap="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
$form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id',-1,1);
@ -1400,8 +1461,8 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top" colspan="2">';
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
print '</textarea></td></tr>';
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
print '</td></tr>';
// Note privee
if (! $user->societe_id)
@ -1409,8 +1470,8 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">';
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">';
print '</textarea></td></tr>';
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
print '</td></tr>';
}
if (is_object($objectsrc))
@ -1797,33 +1858,6 @@ else
print $object->date_livraison ? dol_print_date($object->date_livraison,'daytext') : '&nbsp;';
}
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
print dol_htmlcleanlastbr($object->note_public);
print '</td>';
print '</tr>';
// Delivery address
if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS)
{
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($action != 'editdelivery_adress' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($action == 'editdelivery_adress')
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$socid,'fk_address','commande',$object->id);
}
else
{
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$socid,'none','commande',$object->id);
}
print '</td></tr>';
}
// Terms of payment
print '<tr><td height="10">';
@ -1975,9 +2009,26 @@ else
print '<td colspan="2">'.$object->getLibStatut(4).'</td>';
print '</tr>';
print '</table><br>';
print '</table><br>';
print "\n";
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*
* Lines
*/
@ -2045,16 +2096,11 @@ else
// Send
if ($object->statut > 0)
{
$comref = dol_sanitizeFileName($object->ref);
$file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf';
if (file_exists($file))
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send))
{
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send))
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
}
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
}
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
}
// Ship
@ -2184,7 +2230,33 @@ else
if ($action == 'presend')
{
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref);
$file=$fileparams['fullname'];
// Build document if it not exists
if (! $file || ! is_readable($file))
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0)
{
dol_print_error($db,$result);
exit;
}
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref);
$file=$fileparams['fullname'];
}
print '<br>';
print_titre($langs->trans('SendOrderByMail'));
@ -2210,6 +2282,8 @@ else
$formmail->withcancel=1;
// Tableau des substitutions
$formmail->substit['__ORDERREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']='';
$formmail->substit['__PERSONALIZED__']='';
// Tableau des parametres complementaires
$formmail->param['action']='send';
$formmail->param['models']='order_send';
@ -2217,10 +2291,10 @@ else
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
if (GETPOST("mode")=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf');
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
}
// Show form

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -27,25 +27,24 @@ require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php');
require_once(DOL_DOCUMENT_ROOT ."/commande/class/commande.class.php");
$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
if (!$user->rights->commande->lire) accessforbidden();
$langs->load("companies");
$langs->load("bills");
$langs->load("orders");
$id = GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$socid=GETPOST('socid','int');
$action=GETPOST('action','alpha');
// Security check
$socid=0;
$comid = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'commande',$comid,'');
$result=restrictedArea($user,'commande',$id,'');
$id = $_GET['id'];
$ref= $_GET['ref'];
$commande = new Commande($db);
if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
$object = new Commande($db);
if (! $object->fetch($id, $ref) > 0)
{
dol_print_error($db);
}
@ -55,25 +54,19 @@ if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
* Actions
*/
if ($_POST["action"] == 'update' && $user->rights->commande->creer)
if ($action == 'setnote_public' && $user->rights->commande->creer)
{
$db->begin();
$resPrivateNote=$commande->update_note($_POST["note"]);
$resPublicNote=$commande->update_note_public($_POST["note_public"]);
if ($resPrivateNote < 0 || $resPublicNote < 0)
{
$mesg='<div class="error">'.$commande->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->commande->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
/*
* View
@ -86,17 +79,17 @@ $form = new Form($db);
if ($id > 0 || ! empty($ref))
{
$soc = new Societe($db);
$soc->fetch($commande->socid);
$soc->fetch($object->socid);
$head = commande_prepare_head($commande);
$head = commande_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), 0, 'order');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="18%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($commande,'ref','',1,'ref','ref');
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object,'ref','',1,'ref','ref');
print "</td></tr>";
// Ref commande client
@ -106,7 +99,7 @@ if ($id > 0 || ! empty($ref))
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $commande->ref_client;
print $object->ref_client;
print '</td>';
print '</tr>';
@ -114,64 +107,16 @@ if ($id > 0 || ! empty($ref))
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$soc->getNomUrl(1).'</td></tr>';
// Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<textarea name="note_public" cols="80" rows="'.ROWS_4.'">'.$commande->note_public."</textarea><br>";
}
else
{
print ($commande->note_public?nl2br($commande->note_public):"&nbsp;");
}
print "</td></tr>";
// Note private
if (! $user->societe_id)
{
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<textarea name="note" cols="80" rows="'.ROWS_8.'">'.$commande->note."</textarea><br>";
}
else
{
print ($commande->note?nl2br($commande->note):"&nbsp;");
}
print "</td></tr>";
}
print "</table>";
if ($_GET["action"] == 'edit')
{
print '<br><center>';
print ' <input type="submit" class="button" value="'.$langs->trans('Save').'">';
print '</center>';
print '</form>';
}
print '<br>';
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
print '</div>';
/*
* Actions
*/
print '<div class="tabsAction">';
if ($user->rights->commande->creer && $_GET["action"] <> 'edit')
{
print "<a class=\"butAction\" href=\"note.php?id=".$commande->id."&amp;action=edit\">".$langs->trans('Modify')."</a>";
}
print "</div>";
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -29,7 +29,7 @@ echo '<br>';
print_titre($langs->trans('RelatedOrders'));
?>
<table class="noborder" width="100%">
<table class="noborder allwidth">
<tr class="liste_titre">
<td><?php echo $langs->trans("Ref"); ?></td>
<td align="center"><?php echo $langs->trans("Date"); ?></td>

View File

@ -28,6 +28,12 @@ if (!$user->rights->banque->lire)
accessforbidden();
/**
* Get result of sql for field amount
*
* @param string $sql SQL string
* @return int Amount
*/
function valeur($sql)
{
global $db;

View File

@ -1,36 +1,34 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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/>.
*/
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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/>.
*/
/**
* \file htdocs/compta/bank/class/account.class.php
* \ingroup banque
* \brief File of class to manage bank accounts
*/
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
/**
* \class Account
* \brief Class to manage bank accounts
* Class to manage bank accounts
*/
class Account extends CommonObject
{
@ -46,7 +44,7 @@ class Account extends CommonObject
//! Name
var $bank;
var $clos;
var $rappro; // If bank need to be conciliated
var $rappro=1; // If bank need to be conciliated
var $url;
//! BBAN field for French Code banque
var $code_banque;
@ -130,12 +128,12 @@ class Account extends CommonObject
/**
* Add a link between bank line record and its source
*
* @param line_id Id ecriture bancaire
* @param url_id Id parametre url
* @param url Url
* @param label Link label
* @param type Type of link ('payment', 'company', 'member', ...)
* @return int <0 if KO, id line if OK
* @param int $line_id Id ecriture bancaire
* @param int $url_id Id parametre url
* @param string $url Url
* @param string $label Link label
* @param string $type Type of link ('payment', 'company', 'member', ...)
* @return int <0 if KO, id line if OK
*/
function add_url_line($line_id, $url_id, $url, $label, $type)
{
@ -171,10 +169,10 @@ class Account extends CommonObject
* TODO Move this into AccountLine
* Return array with links from llx_bank_url
*
* @param fk_bank To search using bank transaction id
* @param url_id To search using link to
* @param type To search using type
* @return array Array of links
* @param int $fk_bank To search using bank transaction id
* @param int $url_id To search using link to
* @param string $type To search using type
* @return array Array of links
*/
function get_url($fk_bank='', $url_id='', $type='')
{
@ -227,18 +225,18 @@ class Account extends CommonObject
/**
* Add an entry into table ".MAIN_DB_PREFIX."bank
*
* @param $date Date operation
* @param $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ...
* @param $label Descripton
* @param $amount Amount
* @param $num_chq Numero cheque ou virement
* @param $categorie Categorie optionnelle
* @param $user User that create
* @param $emetteur Name of cheque writer
* @param $banque Bank of cheque writer
* @return int Rowid of added entry, <0 if KO
* @param timsestmap $date Date operation
* @param string $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ...
* @param string $label Descripton
* @param float $amount Amount
* @param string $num_chq Numero cheque ou virement
* @param string $categorie Categorie optionnelle
* @param User $user User that create
* @param string $emetteur Name of cheque writer
* @param string $banque Bank of cheque writer
* @return int Rowid of added entry, <0 if KO
*/
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user, $emetteur='',$banque='')
function addline($date, $oper, $label, $amount, $num_chq, $categorie, $user, $emetteur='',$banque='')
{
// Clean parameters
$emetteur=trim($emetteur);
@ -266,12 +264,12 @@ class Account extends CommonObject
// Check parameters
if (! $oper)
{
$this->error="Account::addline oper not defined";
$this->error="oper not defined";
return -1;
}
if (! $this->rowid)
{
$this->error="Account::addline this->rowid not defined";
$this->error="this->rowid not defined";
return -2;
}
if ($this->courant == 2 && $oper != 'LIQ')
@ -309,7 +307,7 @@ class Account extends CommonObject
$sql.= ", ".($banque?"'".$this->db->escape($banque)."'":"null");
$sql.= ")";
dol_syslog("Account::addline sql=".$sql);
dol_syslog(get_class($this)."::addline sql=".$sql);
if ($this->db->query($sql))
{
$rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank");
@ -337,35 +335,45 @@ class Account extends CommonObject
else
{
$this->error=$this->db->lasterror();
dol_syslog("Account::addline ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::addline ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
}
/**
* Create bank account into database
* Create bank account into database
*
* @param user Object user making action
* @return int < 0 if KO, > 0 if OK
* @param User $user Object user making action
* @return int < 0 if KO, > 0 if OK
*/
function create($user='')
{
global $langs,$conf;
// Check parameters
// Clean parameters
if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0;
if (empty($this->fk_pays))
$this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
$this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
// Check parameters
if (empty($this->country_id))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Country"));
dol_syslog("Account::update ".$this->error, LOG_ERR);
$this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Country"));
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}
if (empty($this->ref))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
dol_syslog("Account::update ".$this->error, LOG_ERR);
$this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref"));
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}
if (empty($this->date_solde))
{
$this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateInitialBalance"));
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}
@ -398,43 +406,48 @@ class Account extends CommonObject
$sql.= ", ".price2num($this->min_allowed);
$sql.= ", ".price2num($this->min_desired);
$sql.= ", '".$this->db->escape($this->comment)."'";
$sql.= ", ".($this->fk_departement>0?"'".$this->fk_departement."'":"null");
$sql.= ", ".$this->fk_pays;
$sql.= ", ".($this->state_id>0?"'".$this->state_id."'":"null");
$sql.= ", ".$this->country_id;
$sql.= ")";
dol_syslog("Account::create sql=".$sql);
dol_syslog(get_class($this)."::create sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->affected_rows($resql))
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account");
if ( $this->update() )
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (";
$sql.= "datec";
$sql.= ", label";
$sql.= ", amount";
$sql.= ", fk_account";
$sql.= ", datev";
$sql.= ", dateo";
$sql.= ", fk_type";
$sql.= ", rappro";
$sql.= ") VALUES (";
$sql.= $this->db->idate($now);
$sql.= ", '(".$langs->trans("InitialBankBalance").")'";
$sql.= ", ".price2num($this->solde);
$sql.= ", '".$this->id."'";
$sql.= ", '".$this->db->idate($this->date_solde)."'";
$sql.= ", '".$this->db->idate($this->date_solde)."'";
$sql.= ", 'SOLD'";
$sql.= ", 0"; // Not conciliated by default
$sql.= ")";
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account");
$this->db->query($sql);
$result=$this->update();
if ($result > 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (";
$sql.= "datec";
$sql.= ", label";
$sql.= ", amount";
$sql.= ", fk_account";
$sql.= ", datev";
$sql.= ", dateo";
$sql.= ", fk_type";
$sql.= ", rappro";
$sql.= ") VALUES (";
$sql.= "'".$this->db->idate($now)."'";
$sql.= ", '(".$langs->trans("InitialBankBalance").")'";
$sql.= ", ".price2num($this->solde);
$sql.= ", '".$this->id."'";
$sql.= ", '".$this->db->idate($this->date_solde)."'";
$sql.= ", '".$this->db->idate($this->date_solde)."'";
$sql.= ", 'SOLD'";
$sql.= ", 0"; // Not conciliated by default
$sql.= ")";
$resql=$this->db->query($sql);
if (! $resql)
{
$this->error=$this->db->lasterror();
dol_syslog($this->error, LOG_ERR);
return -3;
}
return $this->id;
}
return $this->id;
}
else
{
@ -455,26 +468,30 @@ class Account extends CommonObject
/**
* Update bank account card
*
* @param user Object user making action
* @return int <0 si ko, >0 si ok
* @param User $user Object user making action
* @return int <0 si ko, >0 si ok
*/
function update($user='')
{
global $langs,$conf;
// Check parameters
// Clean parameters
if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0;
if (empty($this->fk_pays))
$this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
$this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
// Check parameters
if (empty($this->country_id))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Country"));
dol_syslog("Account::update ".$this->error, LOG_ERR);
$this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Country"));
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1;
}
if (empty($this->ref))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
dol_syslog("Account::update ".$this->error, LOG_ERR);
$this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref"));
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1;
}
if (! $this->label) $this->label = "???";
@ -496,13 +513,13 @@ class Account extends CommonObject
$sql.= ",min_desired = '".price2num($this->min_desired)."'";
$sql.= ",comment = '".$this->db->escape($this->comment)."'";
$sql.= ",fk_departement = ".($this->fk_departement>0?"'".$this->fk_departement."'":"null");
$sql.= ",fk_pays = ".$this->fk_pays;
$sql.= ",fk_departement = ".($this->state_id>0?"'".$this->state_id."'":"null");
$sql.= ",fk_pays = ".$this->country_id;
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Account::update sql=".$sql);
dol_syslog(get_class($this)."::update sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
@ -520,22 +537,26 @@ class Account extends CommonObject
/**
* Update BBAN (RIB) account fields
*
* @param user Object user making update
* @return int <0 if KO, >0 if OK
* @param User $user Object user making update
* @return int <0 if KO, >0 if OK
*/
function update_bban($user='')
{
global $conf,$langs;
// Clean parameters
$this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
$this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
// Chargement librairie pour acces fonction controle RIB
require_once(DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php');
dol_syslog("Account::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
dol_syslog(get_class($this)."::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
// Check parameters
if (! $this->ref)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
$this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->trans("Ref"));
return -2;
}
@ -550,12 +571,12 @@ class Account extends CommonObject
$sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
$sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql.= ",adresse_proprio = '".$this->db->escape($this->adresse_proprio)."'";
$sql.= ",fk_departement = ".($this->fk_departement>0?"'".$this->fk_departement."'":"null");
$sql.= ",fk_pays = ".$this->fk_pays;
$sql.= ",fk_departement = ".($this->state_id>0?"'".$this->state_id."'":"null");
$sql.= ",fk_pays = ".$this->country_id;
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Account::update_bban sql=$sql");
dol_syslog(get_class($this)."::update_bban sql=$sql");
$result = $this->db->query($sql);
if ($result)
@ -574,9 +595,10 @@ class Account extends CommonObject
/**
* Load a bank account into memory from database
*
* @param id Id of bank account to get
* @param ref Ref of bank account to get
* @param ref_ext External ref of bank account to get
* @param int $id Id of bank account to get
* @param string $ref Ref of bank account to get
* @param string $ref_ext External ref of bank account to get
* @return int <0 if KO, >0 if OK
*/
function fetch($id,$ref='',$ref_ext='')
{
@ -602,7 +624,7 @@ class Account extends CommonObject
if ($id) $sql.= " AND ba.rowid = ".$id;
if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'";
dol_syslog("Account::fetch sql=".$sql);
dol_syslog(get_class($this)."::fetch sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
@ -697,8 +719,8 @@ class Account extends CommonObject
/**
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
*
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* @return string Libelle
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* @return string Libelle
*/
function getLibStatut($mode=0)
{
@ -706,10 +728,11 @@ class Account extends CommonObject
}
/**
* Renvoi le libelle d'un statut donne
* @param statut Id statut
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
* Renvoi le libelle d'un statut donne
*
* @param int $statut Id statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
function LibStatut($statut,$mode=0)
{
@ -751,6 +774,7 @@ class Account extends CommonObject
/**
* Renvoi si un compte peut etre supprimer ou non (sans mouvements)
*
* @return boolean vrai si peut etre supprime, faux sinon
*/
function can_be_deleted()
@ -775,6 +799,8 @@ class Account extends CommonObject
/**
* Return error
*
* @return string Error string
*/
function error()
{
@ -856,9 +882,10 @@ class Account extends CommonObject
/**
* Renvoie nom clicable (avec eventuellement le picto)
* @param withpicto Inclut le picto dans le lien
* @param mode ''=Link to card, 'transactions'=Link to transactions card
* @return string Chaine avec URL
*
* @param int $withpicto Inclut le picto dans le lien
* @param string $mode ''=Link to card, 'transactions'=Link to transactions card
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0, $mode='')
{
@ -888,6 +915,7 @@ class Account extends CommonObject
/**
* Return if an account has valid information
*
* @return int 1 if correct, <=0 if wrong
*/
function verif()
@ -913,7 +941,8 @@ class Account extends CommonObject
/**
* Return account country code
* @return String country code
*
* @return string country code
*/
function getCountryCode()
{
@ -948,6 +977,7 @@ class Account extends CommonObject
/**
* Return if a bank account is defined with detailed information (bank code, desk code, number and key)
*
* @return int 0=Use only an account number
* 1=Need Bank, Desk, Number and Key (France, Spain, ...)
* 2=Neek Bank only (BSB for Australia)
@ -970,6 +1000,8 @@ class Account extends CommonObject
*/
function initAsSpecimen()
{
$this->ref = 'MBA';
$this->label = 'My Bank account';
$this->bank = 'MyBank';
$this->courant = 1;
$this->clos = 0;
@ -983,14 +1015,14 @@ class Account extends CommonObject
$this->domiciliation = 'The bank addresse';
$this->proprio = 'Owner';
$this->adresse_proprio = 'Owner address';
$this->country_id = 1;
}
}
/**
* \class AccountLine
* \brief Class to manage bank transaction lines
* Class to manage bank transaction lines
*/
class AccountLine extends CommonObject
{
@ -1032,10 +1064,11 @@ class AccountLine extends CommonObject
/**
* Load into memory content of a bank transaction line
* @param rowid Id of bank transaction to load
* @param ref Ref of bank transaction to load
* @param num External num to load (ex: num of transaction for paypal fee)
* @return int <0 if KO, >0 if OK
*
* @param int $rowid Id of bank transaction to load
* @param string $ref Ref of bank transaction to load
* @param string $num External num to load (ex: num of transaction for paypal fee)
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid,$ref='',$num='')
{
@ -1058,7 +1091,7 @@ class AccountLine extends CommonObject
else if ($ref) $sql.= " AND b.rowid='".$ref."'";
else $sql.= " AND b.rowid=".$rowid;
dol_syslog("AccountLine::fetch sql=".$sql);
dol_syslog(get_class($this)."::fetch sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
@ -1104,8 +1137,8 @@ class AccountLine extends CommonObject
/**
* Delete transaction bank line record
*
* @param user User object that delete
* @return int <0 if KO, >0 if OK
* @param User $user User object that delete
* @return int <0 if KO, >0 if OK
*/
function delete($user=0)
{
@ -1128,12 +1161,12 @@ class AccountLine extends CommonObject
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid;
dol_syslog("AccountLine::delete sql=".$sql);
dol_syslog(get_class($this)."::delete sql=".$sql);
$result = $this->db->query($sql);
if (! $result) $nbko++;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$this->rowid;
dol_syslog("AccountLine::delete sql=".$sql);
dol_syslog(get_class($this)."::delete sql=".$sql);
$result = $this->db->query($sql);
if (! $result) $nbko++;
@ -1153,8 +1186,8 @@ class AccountLine extends CommonObject
/**
* Delete bank line records
*
* @param user User object that delete
* @return int <0 if KO, >0 if OK
* @param User $user User object that delete
* @return int <0 if KO, >0 if OK
*/
function delete_urls($user=0)
{
@ -1170,7 +1203,7 @@ class AccountLine extends CommonObject
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$this->rowid;
dol_syslog("AccountLine::delete_urls sql=".$sql);
dol_syslog(get_class($this)."::delete_urls sql=".$sql);
$result = $this->db->query($sql);
if (! $result) $nbko++;
@ -1190,9 +1223,9 @@ class AccountLine extends CommonObject
/**
* Update bank account record in database
*
* @param user Object user making update
* @param notrigger 0=Disable all triggers
* @return int <0 if KO, >0 if OK
* @param User $user Object user making update
* @param int $notrigger 0=Disable all triggers
* @return int <0 if KO, >0 if OK
*/
function update($user,$notrigger=0)
{
@ -1204,7 +1237,7 @@ class AccountLine extends CommonObject
$sql.= " dateo='".$this->db->idate($this->dateo)."'";
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("AccountLine::update sql=".$sql);
dol_syslog(get_class($this)."::update sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@ -1215,7 +1248,7 @@ class AccountLine extends CommonObject
{
$this->db->rollback();
$this->error=$this->db->error();
dol_syslog("AccountLine::update ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1;
}
}
@ -1224,9 +1257,9 @@ class AccountLine extends CommonObject
/**
* Update conciliation field
*
* @param user Objet user making update
* @param cat Category id
* @return int <0 if KO, >0 if OK
* @param User $user Objet user making update
* @param int $cat Category id
* @return int <0 if KO, >0 if OK
*/
function update_conciliation($user,$cat)
{
@ -1238,7 +1271,7 @@ class AccountLine extends CommonObject
$sql.= ", fk_user_rappro = ".$user->id;
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("AccountLine::update_conciliation sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::update_conciliation sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -1252,7 +1285,7 @@ class AccountLine extends CommonObject
$sql.= ", ".$cat;
$sql.= ")";
dol_syslog("AccountLine::update_conciliation sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::update_conciliation sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
// No error check. Can fail if category already affected
@ -1274,8 +1307,8 @@ class AccountLine extends CommonObject
/**
* Increase/decrease value date of a rowid
*
* @param int $rowid
* @param int sign 1 or -1
* @param int $rowid Id of line
* @param int $sign 1 or -1
* @return int >0 if OK, 0 if KO
*/
function datev_change($rowid,$sign=1)
@ -1335,7 +1368,8 @@ class AccountLine extends CommonObject
/**
* Charge les informations d'ordre info dans l'objet
*
* @param rowid Id of object
* @param int $rowid Id of object
* @return void
*/
function info($rowid)
{
@ -1380,10 +1414,10 @@ class AccountLine extends CommonObject
/**
* Renvoie nom clicable (avec eventuellement le picto)
*
* @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param maxlen Longueur max libelle
* @param option Option ('showall')
* @return string Chaine avec URL
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param int $maxlen Longueur max libelle
* @param string $option Option ('showall')
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$maxlen=0,$option='')
{

View File

@ -58,9 +58,9 @@ class BankCateg // extends CommonObject
/**
* Create in database
*
* @param user User that create
* @param notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK
* @param User $user User that create
* @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)
{
@ -126,9 +126,10 @@ class BankCateg // extends CommonObject
/**
* \brief Load object in memory from database
* \param id id object
* \return int <0 if KO, >0 if OK
* Load object in memory from database
*
* @param int $id Id object
* @return int <0 if KO, >0 if OK
*/
function fetch($id)
{
@ -166,10 +167,11 @@ class BankCateg // extends CommonObject
/**
* \brief Update database
* \param user User that modify
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
* Update database
*
* @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
@ -230,10 +232,11 @@ class BankCateg // extends CommonObject
/**
* \brief Delete object in database
* \param user User that delete
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger=0)
{
@ -287,9 +290,10 @@ class BankCateg // extends CommonObject
/**
* \brief Load an object from its id and create a new one in database
* \param fromid Id of object to clone
* \return int New id of clone
* 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
*/
function createFromClone($fromid)
{

View File

@ -508,7 +508,7 @@ else
// Type
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("AccountType").'</td>';
print '<td colspan="3">';
print $form->select_type_comptes_financiers((isset($_POST["type"])?$_POST["type"]:$account->type),"type");
print $formbank->select_type_comptes_financiers((isset($_POST["type"])?$_POST["type"]:$account->type),"type");
print '</td></tr>';
// Currency

View File

@ -229,7 +229,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
// Sort array
if (! $error)
{
array_multisort ($tab_sqlobjOrder,$tab_sqlobj);
array_multisort($tab_sqlobjOrder,$tab_sqlobj);
//Apply distinct filter
foreach ($tab_sqlobj as $key=>$value) {

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copytight (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copytight (C) 2012 Juanjo Menent <jmenent@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
@ -31,18 +32,20 @@ $langs->load("banks");
if (! $user->rights->banque->transfer)
accessforbidden();
$action = GETPOST('action','alpha');
/*
* Action ajout d'un virement
*/
if ($_POST["action"] == 'add')
if ($action == 'add')
{
$langs->load("errors");
$mesg='';
$dateo = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
$label = $_POST["label"];
$amount= $_POST["amount"];
$dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
$label = GETPOST('label','alpha');
$amount= GETPOST('amount','int');
if (! $label)
{
@ -54,12 +57,12 @@ if ($_POST["action"] == 'add')
$error=1;
$mesg.="<div class=\"error\">".$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"))."</div>";
}
if (! $_POST['account_from'])
if (! GETPOST('account_from','int'))
{
$error=1;
$mesg.="<div class=\"error\">".$langs->trans("ErrorFieldRequired",$langs->transnoentities("TransferFrom"))."</div>";
}
if (! $_POST['account_to'])
if (! GETPOST('account_to','int'))
{
$error=1;
$mesg.="<div class=\"error\">".$langs->trans("ErrorFieldRequired",$langs->transnoentities("TransferTo"))."</div>";
@ -69,10 +72,10 @@ if ($_POST["action"] == 'add')
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
$accountfrom=new Account($db);
$accountfrom->fetch($_POST["account_from"]);
$accountfrom->fetch(GETPOST('account_from','int'));
$accountto=new Account($db);
$accountto->fetch($_POST["account_to"]);
$accountto->fetch(GETPOST('account_to','int'));
if ($accountto->id != $accountfrom->id)
{
@ -133,6 +136,18 @@ llxHeader();
$form=new Form($db);
$account_from='';
$account_to='';
$label='';
$amount='';
if($error)
{
$account_from = GETPOST('account_from','int');
$account_to = GETPOST('account_to','int');
$label = GETPOST('label','alpha');
$amount = GETPOST('amount','int');
}
print_fiche_titre($langs->trans("BankTransfer"));
@ -153,18 +168,18 @@ print '</tr>';
$var=false;
print '<tr '.$bc[$var].'><td>';
print $form->select_comptes($_POST['account_from'],'account_from',0,'',1);
print $form->select_comptes($account_from,'account_from',0,'',1);
print "</td>";
print "<td>\n";
print $form->select_comptes($_POST['account_to'],'account_to',0,'',1);
print $form->select_comptes($account_to,'account_to',0,'',1);
print "</td>\n";
print "<td>";
$form->select_date($dateo,'','','','','add');
print "</td>\n";
print '<td><input name="label" class="flat" type="text" size="40" value="'.$_POST["label"].'"></td>';
print '<td><input name="amount" class="flat" type="text" size="8" value="'.$_POST["amount"].'"></td>';
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>';
print "</table>";

View File

@ -64,13 +64,6 @@ llxHeader();
$thirdpartystatic=new Societe($db);
if ($action == 'attribute_prefix')
{
$societe = new Societe($db);
$societe->fetch($socid);
$societe->attribute_prefix($db, $socid);
}
if ($action == 'note')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$note."' WHERE rowid=".$socid;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis@dolibarr.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
@ -50,6 +50,7 @@ class Deplacement extends CommonObject
var $socid;
var $statut; // 0=draft, 1=validated
var $fk_project;
var $extraparams=array();
/**
* Constructor
@ -209,7 +210,7 @@ class Deplacement extends CommonObject
*/
function fetch($id)
{
$sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note, note_public, fk_projet";
$sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note, note_public, fk_projet, extraparams";
$sql.= " FROM ".MAIN_DB_PREFIX."deplacement";
$sql.= " WHERE rowid = ".$id;
@ -230,6 +231,8 @@ class Deplacement extends CommonObject
$this->note_private = $obj->note;
$this->note_public = $obj->note_public;
$this->fk_project = $obj->fk_projet;
$this->extraparams = (array) json_decode($obj->extraparams, true);
return 1;
}

View File

@ -108,9 +108,10 @@ class DeplacementStats extends Stats
/**
* \brief Renvoie le montant de facture par mois pour une annee donnee
* \param year Year to scan
* \return array Array of values
* Renvoie le montant de facture par mois pour une annee donnee
*
* @param int $year Year to scan
* @return array Array of values
*/
function getAmountByMonth($year)
{
@ -127,9 +128,10 @@ class DeplacementStats extends Stats
}
/**
* \brief Return average amount
* \param year Year to scan
* \return array Array of values
* Return average amount
*
* @param int $year Year to scan
* @return array Array of values
*/
function getAverageByMonth($year)
{
@ -144,8 +146,9 @@ class DeplacementStats extends Stats
}
/**
* \brief Return nb, total and average
* \return array Array of values
* Return nb, total and average
*
* @return array Array of values
*/
function getAllByYear()
{

View File

@ -1,18 +1,18 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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/>.
*/
@ -70,7 +70,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer)
}
/*
if ($action == 'unblock' && $user->rights->deplacement->unvalidate)
else if ($action == 'unblock' && $user->rights->deplacement->unvalidate)
{
$object->fetch($id);
if ($object->fk_statut == '1') // Not blocked...
@ -99,7 +99,7 @@ if ($action == 'unblock' && $user->rights->deplacement->unvalidate)
}
}*/
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer)
else if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer)
{
$result=$object->delete($id);
if ($result >= 0)
@ -113,7 +113,7 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplaceme
}
}
if ($action == 'add' && $user->rights->deplacement->creer)
else if ($action == 'add' && $user->rights->deplacement->creer)
{
if (! $_POST["cancel"])
{
@ -172,13 +172,13 @@ if ($action == 'add' && $user->rights->deplacement->creer)
}
// Update record
if ($action == 'update' && $user->rights->deplacement->creer)
else if ($action == 'update' && $user->rights->deplacement->creer)
{
if (empty($_POST["cancel"]))
{
$result = $object->fetch($id);
$object->date = dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$object->date = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$object->km = $_POST["km"];
$object->type = $_POST["type"];
$object->fk_user = $_POST["fk_user"];
@ -206,7 +206,7 @@ if ($action == 'update' && $user->rights->deplacement->creer)
}
// Set into a project
if ($action == 'classin')
else if ($action == 'classin' && $user->rights->deplacement->creer)
{
$object->fetch($id);
$result=$object->setProject($_POST['projectid']);
@ -214,26 +214,26 @@ if ($action == 'classin')
}
// Set fields
if ($action == 'setdated')
else if ($action == 'setdated' && $user->rights->deplacement->creer)
{
$dated=dol_mktime($_POST['datedhour'], $_POST['datedmin'], $_POST['datedsec'], $_POST['datedmonth'], $_POST['datedday'], $_POST['datedyear']);
$object->fetch($id);
$result=$object->setValueFrom('dated',$dated,'','','date');
if ($result < 0) dol_print_error($db, $object->error);
}
if ($action == 'setkm')
else if ($action == 'setkm' && $user->rights->deplacement->creer)
{
$object->fetch($id);
$result=$object->setValueFrom('km',GETPOST('km'));
if ($result < 0) dol_print_error($db, $object->error);
}
if ($action == 'setnote_public')
else if ($action == 'setnote_public' && $user->rights->deplacement->creer)
{
$object->fetch($id);
$result=$object->setValueFrom('note_public',GETPOST('note_public'));
if ($result < 0) dol_print_error($db, $object->error);
}
if ($action == 'setnote')
else if ($action == 'setnote' && $user->rights->deplacement->creer)
{
$object->fetch($id);
$result=$object->setValueFrom('note',GETPOST('note'));
@ -424,7 +424,7 @@ else if ($id)
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>';
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object,'id','',1,'rowid','ref','');
print '</td></tr>';
@ -495,24 +495,12 @@ else if ($id)
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Public note
print '<tr><td valign="top">';
print $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180');
print '</td><td>';
print $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180');
print "</td></tr>";
print "</table><br>";
// Private note
if (! $user->societe_id)
{
print '<tr><td valign="top">';
print $form->editfieldkey("NotePrivate",'note',$object->note_private,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180');
print '</td><td>';
print $form->editfieldval("NotePrivate",'note',$object->note_private,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180');
print "</td></tr>";
}
print "</table>";
// Notes
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
print '</div>';

View File

@ -75,7 +75,7 @@ if (trim($search_ref) != '')
$sql.= ' AND d.rowid LIKE \'%'.$db->escape(trim($search_ref)) . '%\'';
}
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1 ,$offset);
$sql.= $db->plimit($limit + 1, $offset);
//print $sql;
$resql=$db->query($sql);

View File

@ -38,8 +38,12 @@ require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php');
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php');
if ($conf->projet->enabled)
{
require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php');
}
$langs->load('bills');
//print 'ee'.$langs->trans('BillsCustomer');exit;
@ -91,7 +95,7 @@ $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes')
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer)
{
if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
{
@ -117,7 +121,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
}
// Change status of invoice
if ($action == 'reopen' && $user->rights->facture->creer)
else if ($action == 'reopen' && $user->rights->facture->creer)
{
$result = $object->fetch($id);
if ($object->statut == 2
@ -137,77 +141,68 @@ if ($action == 'reopen' && $user->rights->facture->creer)
}
// Delete invoice
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer)
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer)
{
if ($user->rights->facture->supprimer)
{
$result = $object->fetch($id);
$result = $object->delete();
if ($result > 0)
{
Header('Location: '.$_SERVER["PHP_SELF"]);
exit;
}
else
{
$mesg='<div class="error">'.$object->error.'</div>';
}
}
$result = $object->fetch($id);
$result = $object->delete();
if ($result > 0)
{
Header('Location: '.$_SERVER["PHP_SELF"]);
exit;
}
else
{
$mesg='<div class="error">'.$object->error.'</div>';
}
}
// Delete line
if ($action == 'confirm_deleteline' && $confirm == 'yes')
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
{
if ($user->rights->facture->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid'], $user);
if ($result > 0)
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
if ($result >= 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
}
else
{
$mesg='<div clas="error">'.$object->error.'</div>';
$action='';
}
}
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->deleteline($_GET['lineid'], $user);
if ($result > 0)
{
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
if ($result >= 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
}
}
else
{
$mesg='<div clas="error">'.$object->error.'</div>';
$action='';
}
}
// Delete link of credit note to invoice
if ($action == 'unlinkdiscount')
else if ($action == 'unlinkdiscount' && $user->rights->facture->creer)
{
if ($user->rights->facture->creer)
{
$discount=new DiscountAbsolute($db);
$result=$discount->fetch($_GET["discountid"]);
$discount->unlink_invoice();
}
$discount=new DiscountAbsolute($db);
$result=$discount->fetch($_GET["discountid"]);
$discount->unlink_invoice();
}
// Validation
if ($action == 'valid')
else if ($action == 'valid' && $user->rights->facture->creer)
{
$object->fetch($id);
@ -224,7 +219,7 @@ if ($action == 'valid')
else
{
// Si non avoir, le signe doit etre positif
if ($object->total_ht < 0)
if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0)
{
$mesg='<div class="error">'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'</div>';
$action='';
@ -232,7 +227,7 @@ if ($action == 'valid')
}
}
if ($action == 'set_thirdparty')
else if ($action == 'set_thirdparty' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->setValueFrom('fk_soc',$socid);
@ -241,20 +236,20 @@ if ($action == 'set_thirdparty')
exit;
}
if ($action == 'classin')
else if ($action == 'classin' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->setProject($_POST['projectid']);
}
if ($action == 'setmode')
else if ($action == 'setmode' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->mode_reglement($_POST['mode_reglement_id']);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setinvoicedate')
else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']);
@ -263,28 +258,20 @@ if ($action == 'setinvoicedate')
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setpaymentterm')
else if ($action == 'setconditions' && $user->rights->facture->creer)
{
$object->fetch($id);
$date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']);
$result=$object->cond_reglement($object->cond_reglement_id,$date_lim_reglement);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setconditions')
{
$object->fetch($id);
$result=$object->cond_reglement($_POST['cond_reglement_id']);
if ($result < 0) dol_print_error($db,$object->error);
}
if ($action == 'setremisepercent' && $user->rights->facture->creer)
else if ($action == 'setremisepercent' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->set_remise($user, $_POST['remise_percent']);
}
if ($action == "setabsolutediscount" && $user->rights->facture->creer)
else if ($action == "setabsolutediscount" && $user->rights->facture->creer)
{
// POST[remise_id] ou POST[remise_id_for_payment]
if (! empty($_POST["remise_id"]))
@ -317,14 +304,28 @@ if ($action == "setabsolutediscount" && $user->rights->facture->creer)
}
}
if ($action == 'set_ref_client')
else if ($action == 'set_ref_client' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->set_ref_client($_POST['ref_client']);
}
else if ($action == 'setnote_public' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->facture->creer)
{
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
// Classify to validated
if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider)
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider)
{
$idwarehouse=GETPOST('idwarehouse');
@ -371,7 +372,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v
}
// Go back to draft status (unvalidate)
if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate))
else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate))
{
$idwarehouse=GETPOST('idwarehouse');
@ -444,13 +445,13 @@ if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS
}
// Classify "paid"
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement)
else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement)
{
$object->fetch($id);
$result = $object->set_paid($user);
}
// Classif "paid partialy"
if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement)
else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement)
{
$object->fetch($id);
$close_code=$_POST["close_code"];
@ -465,7 +466,7 @@ if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->f
}
}
// Classify "abandoned"
if ($action == 'confirm_canceled' && $confirm == 'yes')
else if ($action == 'confirm_canceled' && $confirm == 'yes')
{
$object->fetch($id);
$close_code=$_POST["close_code"];
@ -481,7 +482,7 @@ if ($action == 'confirm_canceled' && $confirm == 'yes')
}
// Convertir en reduc
if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
{
$db->begin();
@ -556,7 +557,7 @@ if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->f
/*
* Insert new invoice in database
*/
if ($action == 'add' && $user->rights->facture->creer)
else if ($action == 'add' && $user->rights->facture->creer)
{
$object->socid=GETPOST('socid','int');
@ -739,10 +740,11 @@ if ($action == 'add' && $user->rights->facture->creer)
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
if ($element == 'contract') { $element = $subelement = 'contrat'; }
if ($element == 'inter') { $element = $subelement = 'ficheinter'; }
if ($element == 'shipping') {$element = $subelement = 'expedition'; }
$object->origin = $_POST['origin'];
$object->origin_id = $_POST['originid'];
// Possibility to add external linked objects with hooks
$object->linked_objects[$object->origin] = $object->origin_id;
if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects']))
@ -916,7 +918,7 @@ if ($action == 'add' && $user->rights->facture->creer)
}
// Add a new line
if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer)
else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer)
{
$result=0;
@ -1124,7 +1126,7 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact
$action='';
}
if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save'))
else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save'))
{
if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty();
@ -1212,15 +1214,14 @@ if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save']
}
}
if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel'))
else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel'))
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // Pour reaffichage de la fiche en cours d'edition
exit;
}
// Modify line position (up)
if ($action == 'up' && $user->rights->facture->creer)
else if ($action == 'up' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
@ -1242,7 +1243,7 @@ if ($action == 'up' && $user->rights->facture->creer)
exit;
}
// Modify line position (down)
if ($action == 'down' && $user->rights->facture->creer)
else if ($action == 'down' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
@ -1311,11 +1312,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if ($result > 0)
{
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
// $ref = dol_sanitizeFileName($object->ref);
// $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (is_readable($file))
{
// if (is_readable($file))
// {
if ($_POST['sendto'])
{
// Le destinataire a ete fourni via le champ libre
@ -1444,13 +1445,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$mesg.='</div>';
}
}
}
/* }
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>';
dol_syslog('Recipient email is empty');
}
}*/
}
else
{
@ -1472,7 +1473,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
/*
* Generate document
*/
if (GETPOST('action') == 'builddoc') // En get ou en post
else if ($action == 'builddoc') // En get ou en post
{
$object->fetch($id);
$object->fetch_thirdparty();
@ -1505,6 +1506,66 @@ if (GETPOST('action') == 'builddoc') // En get ou en post
}
}
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
if ($action == 'addcontact' && $user->rights->facture->creer)
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
else if ($action == 'swapstatut' && $user->rights->facture->creer)
{
if ($object->fetch($id))
{
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
dol_print_error($db);
}
}
}
/*
@ -2093,8 +2154,11 @@ else
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
}
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,"yes",($conf->notification->enabled?0:2));
if ($object->type != 2 && $object->total_ttc < 0) // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on
{
$text.='<br>'.img_warning().' '.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive");
}
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,(($object->type != 2 && $object->total_ttc < 0)?"no":"yes"),($conf->notification->enabled?0:2));
}
// Confirm back to draft status
@ -2349,7 +2413,7 @@ else
if ($absolute_creditnote > 0) // If not, link will be added later
{
if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.')<br>';
else print '.';
else print '. ';
}
else print '. ';
}
@ -2372,7 +2436,8 @@ else
{
// Remise dispo de type avoir
if (! $absolute_discount) print '<br>';
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
//$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0); // We must allow credit not even if amount is higher
}
}
if (! $absolute_discount && ! $absolute_creditnote)
@ -2733,6 +2798,23 @@ else
print '</table><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$formcompany= new FormCompany($db);
$blocname = 'contacts';
$title = $langs->trans('ContactsAddresses');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$blocname = 'notes';
$title = $langs->trans('Notes');
include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php');
}
/*
* Lines
@ -2826,14 +2908,13 @@ else
// Validate
if ($object->statut == 0 && count($object->lines) > 0 &&
(
(($object->type == 0 || $object->type == 1 || $object->type == 3 || $object->type == 4) && $object->total_ttc >= 0)
(($object->type == 0 || $object->type == 1 || $object->type == 3 || $object->type == 4) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0))
|| ($object->type == 2 && $object->total_ttc <= 0))
)
{
if ($user->rights->facture->valider)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=valid"';
print '>'.$langs->trans('Validate').'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=valid">'.$langs->trans('Validate').'</a>';
}
}
@ -3049,10 +3130,12 @@ else
}
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref);
$file=$fileparams['fullname'];
// Construit PDF si non existant
if (! is_readable($file))
// Build document if it not exists
if (! $file || ! is_readable($file))
{
// Define output language
$outputlangs = $langs;
@ -3064,12 +3147,15 @@ else
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=facture_pdf_create($db, $object, $_REQUEST['model'], $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
$result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0)
{
dol_print_error($db,$result);
exit;
}
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref);
$file=$fileparams['fullname'];
}
print '<br>';
@ -3096,6 +3182,8 @@ else
$formmail->withcancel=1;
// Tableau des substitutions
$formmail->substit['__FACREF__']=$object->ref;
$formmail->substit['__SIGNATURE__']='';
$formmail->substit['__PERSONALIZED__']='';
// Tableau des parametres complementaires du post
$formmail->param['action']=$action;
$formmail->param['models']=$modelmail;
@ -3103,10 +3191,10 @@ else
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
if (GETPOST("mode")=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf');
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
}
$formmail->show_form();
@ -3379,7 +3467,7 @@ else
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -72,7 +72,8 @@ class Facture extends CommonObject
var $total_ht=0;
var $total_tva=0;
var $total_ttc=0;
var $note;
var $note; // deprecated
var $note_private;
var $note_public;
//! 0=draft,
//! 1=validated (need to be paid),
@ -101,6 +102,7 @@ class Facture extends CommonObject
var $products=array(); // deprecated
var $lines=array();
var $line;
var $extraparams=array();
//! Pour board
var $nbtodo;
var $nbtodolate;
@ -134,7 +136,8 @@ class Facture extends CommonObject
// Clean parameters
if (empty($this->type)) $this->type = 0;
$this->ref_client=trim($this->ref_client);
$this->note=trim($this->note);
$this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated
$this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note));
$this->note_public=trim($this->note_public);
if (! $this->cond_reglement_id) $this->cond_reglement_id = 0;
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
@ -217,7 +220,7 @@ class Facture extends CommonObject
$sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL');
$sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL');
$sql.= ", '".$this->db->idate($this->date)."'";
$sql.= ",".($this->note?"'".$this->db->escape($this->note)."'":"null");
$sql.= ",".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ",".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ",".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null");
$sql.= ",".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
@ -253,6 +256,32 @@ class Facture extends CommonObject
dol_print_error($this->db);
$error++;
}
// TODO mutualiser
if ($origin == 'commande')
{
// On recupere les differents contact interne et externe
$order = new Commande($this->db);
$order->id = $origin_id;
// On recupere le commercial suivi propale
$this->userid = $order->getIdcontact('internal', 'SALESREPFOLL');
if ($this->userid)
{
//On passe le commercial suivi commande en commercial suivi paiement
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
}
// On recupere le contact client facturation commande
$this->contactid = $order->getIdcontact('external', 'BILLING');
if ($this->contactid)
{
//On passe le contact client facturation commande en contact client facturation
$this->add_contact($this->contactid[0], 'BILLING', 'external');
}
}
}
}
@ -643,8 +672,15 @@ class Facture extends CommonObject
$this->note = $object->note;
$this->note_public = $object->note_public;
$this->origin = $object->element;
$this->origin_id = $object->id;
$this->origin = $object->element;
$this->origin_id = $object->id;
// 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))
{
$this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
}
$ret = $this->create($user);
@ -730,9 +766,9 @@ class Facture extends CommonObject
$sql.= ', f.datec as datec';
$sql.= ', f.date_valid as datev';
$sql.= ', f.tms as datem';
$sql.= ', f.note, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf';
$sql.= ', f.note as note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf';
$sql.= ', f.fk_facture_source';
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet';
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
@ -785,12 +821,15 @@ class Facture extends CommonObject
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
$this->fk_project = $obj->fk_projet;
$this->fk_facture_source = $obj->fk_facture_source;
$this->note = $obj->note;
$this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid;
$this->modelpdf = $obj->model_pdf;
$this->extraparams = (array) json_decode($obj->extraparams, true);
if ($this->statut == 0) $this->brouillon = 1;
/*
@ -926,7 +965,8 @@ class Facture extends CommonObject
if (isset($this->increment)) $this->increment=trim($this->increment);
if (isset($this->close_code)) $this->close_code=trim($this->close_code);
if (isset($this->close_note)) $this->close_note=trim($this->close_note);
if (isset($this->note)) $this->note=trim($this->note);
if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated
if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note));
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
if (isset($this->import_key)) $this->import_key=trim($this->import_key);
@ -964,7 +1004,7 @@ class Facture extends CommonObject
$sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").",";
$sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").",";
$sql.= " date_lim_reglement=".(strval($this->date_lim_reglement)!='' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').",";
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
$sql.= " note=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").",";
$sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").",";
$sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").",";
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null")."";
@ -2660,91 +2700,6 @@ class Facture extends CommonObject
}
}
/**
* Change les conditions de reglement de la facture
*
* @param int $cond_reglement_id Id de la nouvelle condition de reglement
* @param date $date Date to force payment term
* @return int >0 si ok, <0 si ko
*/
function cond_reglement($cond_reglement_id,$date='')
{
if ($this->statut >= 0 && $this->paye == 0)
{
// Define cond_reglement_id and datelim
if (strval($date) != '')
{
$datelim=$date;
$cond_reglement_id=0;
}
else
{
$datelim=$this->calculate_date_lim_reglement($cond_reglement_id);
$cond_reglement_id=$cond_reglement_id;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET fk_cond_reglement = '.$cond_reglement_id.',';
$sql.= ' date_lim_reglement='.$this->db->idate($datelim);
$sql.= ' WHERE rowid='.$this->id;
dol_syslog(get_class($this)."::cond_reglement sql=".$sql, LOG_DEBUG);
if ( $this->db->query($sql) )
{
$this->cond_reglement_id = $cond_reglement_id;
return 1;
}
else
{
dol_syslog(get_class($this)."::cond_reglement Erreur ".$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this)."::cond_reglement, etat facture incompatible");
$this->error='Entity status not compatible '.$this->statut.' '.$this->paye;
return -2;
}
}
/**
* Change le mode de reglement
*
* @param int $mode_reglement_id Id du nouveau mode
* @return int >0 if OK, <0 if KO
*/
function mode_reglement($mode_reglement_id)
{
dol_syslog(get_class($this).'::mode_reglement('.$mode_reglement_id.')', LOG_DEBUG);
if ($this->statut >= 0 && $this->paye == 0)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql .= ' SET fk_mode_reglement = '.$mode_reglement_id;
$sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
{
$this->mode_reglement_id = $mode_reglement_id;
return 1;
}
else
{
dol_syslog(get_class($this).'::mode_reglement Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::mode_reglement, etat facture incompatible');
$this->error='Etat facture incompatible '.$this->statut.' '.$this->paye;
return -2;
}
}
/**
* Renvoi si les lignes de facture sont ventilees et/ou exportees en compta
*
@ -3118,12 +3073,14 @@ class Facture extends CommonObject
$this->specimen=1;
$this->socid = 1;
$this->date = $nownotime;
$this->date_lim_reglement = $nownotime + 3600 * 24 *30;
$this->cond_reglement_id = 1;
$this->cond_reglement_code = 'RECEP';
$this->date_lim_reglement=$this->calculate_date_lim_reglement();
$this->mode_reglement_id = 7;
$this->mode_reglement_code = 'CHQ';
$this->note_public='This is a comment (public)';
$this->note_private='This is a comment (private)';
$this->note='This is a comment (private)';
if (empty($option) || $option != 'nolines')

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -32,56 +33,57 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$langs->load("bills");
$langs->load("companies");
$facid = GETPOST('facid');
$id = GETPOST('facid');
$ref= GETPOST('ref');
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref = GETPOST('ref');
$socid=GETPOST('socid','int');
$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'facture', $facid);
$result = restrictedArea($user, 'facture', $id);
$object = new Facture($db);
/*
* Ajout d'un nouveau contact
*/
if ($_POST["action"] == 'addcontact' && $user->rights->facture->creer)
if ($action == 'addcontact' && $user->rights->facture->creer)
{
$result = 0;
$facture = new Facture($db);
$result = $facture->fetch($facid);
$result = $object->fetch($id);
if ($result > 0 && $facid > 0)
if ($result > 0 && $id > 0)
{
$result = $facture->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: contact.php?facid=".$facture->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
if ($facture->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$facture->error.'</div>';
$mesg = '<div class="error">'.$object->error.'</div>';
}
}
}
// bascule du statut d'un contact
if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer)
else if ($action == 'swapstatut' && $user->rights->facture->creer)
{
$facture = new Facture($db);
if ($facture->fetch($facid))
if ($object->fetch($id))
{
$result=$facture->swapContactStatus(GETPOST('ligne'));
$result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
@ -90,15 +92,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer)
}
// Efface un contact
if ($_GET["action"] == 'deleteline' && $user->rights->facture->creer)
else if ($action == 'deletecontact' && $user->rights->facture->creer)
{
$facture = new Facture($db);
$facture->fetch($facid);
$result = $facture->delete_contact($_GET["lineid"]);
$object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0)
{
Header("Location: contact.php?facid=".$facture->id);
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
@ -128,12 +129,11 @@ dol_htmloutput_mesg($mesg);
if ($id > 0 || ! empty($ref))
{
$facture = new Facture($db);
if ($facture->fetch($id, $ref) > 0)
if ($object->fetch($id, $ref) > 0)
{
$facture->fetch_thirdparty();
$object->fetch_thirdparty();
$head = facture_prepare_head($facture);
$head = facture_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), 0, 'bill');
@ -147,7 +147,7 @@ if ($id > 0 || ! empty($ref))
print '<td colspan="3">';
$morehtmlref='';
$discount=new DiscountAbsolute($db);
$result=$discount->fetch(0,$facture->id);
$result=$discount->fetch(0,$object->id);
if ($result > 0)
{
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
@ -156,198 +156,20 @@ if ($id > 0 || ! empty($ref))
{
dol_print_error('',$discount->error);
}
print $form->showrefnav($facture,'ref','',1,'facnumber','ref',$morehtmlref);
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>';
// Customer
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$facture->client->getNomUrl(1,'compta').'</td></tr>';
print '<td colspan="3">'.$object->client->getNomUrl(1,'compta').'</td></tr>';
print "</table>";
print '</div>';
/*
* Lignes de contacts
*/
echo '<br><table class="noborder" width="100%">';
/*
* Ajouter une ligne de contact
* Non affiche en mode modification de ligne
*/
if ($_GET["action"] != 'editline' && $user->rights->facture->creer)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td colspan="3">&nbsp;</td>';
print "</tr>\n";
$var = false;
print '<form action="contact.php?facid='.$id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="internal">';
print '<input type="hidden" name="id" value="'.$id.'">';
// Line to add an internal contact
print "<tr ".$bc[$var].">";
print '<td nowrap="nowrap">';
print img_object('','user').' '.$langs->trans("Users");
print '</td>';
print '<td colspan="1">';
print $mysoc->name;
print '</td>';
print '<td colspan="1">';
// Ge get ids of alreadey selected users
//$userAlreadySelected = $facture->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$form->select_users($user->id,'contactid',0,$userAlreadySelected);
print '</td>';
print '<td>';
$formcompany->selectTypeContact($facture, '', 'type','internal');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
print '</form>';
print '<form action="contact.php?facid='.$id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="external">';
print '<input type="hidden" name="id" value="'.$id.'">';
// Line to add an external contact
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td nowrap="nowrap">';
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
print '</td>';
print '<td nowrap="nowrap">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany');
print '</td>';
print '<td>';
$nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid');
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$formcompany->selectTypeContact($facture, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="disabled"';
print '></td>';
print '</tr>';
print "</form>";
print '<tr><td colspan="6">&nbsp;</td></tr>';
}
// List of linked contacts
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td align="center">'.$langs->trans("Status").'</td>';
print '<td colspan="2">&nbsp;</td>';
print "</tr>\n";
$companystatic = new Societe($db);
$var = true;
foreach(array('internal','external') as $source)
{
$tab = $facture->liste_contact(-1,$source);
$num=count($tab);
$i = 0;
while ($i < $num)
{
$var = !$var;
print '<tr '.$bc[$var].' valign="top">';
// Source
print '<td align="left">';
if ($tab[$i]['source']=='internal') print $langs->trans("User");
if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact");
print '</td>';
// Third party
print '<td align="left">';
if ($tab[$i]['socid'] > 0)
{
$companystatic->fetch($tab[$i]['socid']);
print $companystatic->getNomUrl(1);
}
if ($tab[$i]['socid'] < 0)
{
print $mysoc->name;
}
if (! $tab[$i]['socid'])
{
print '&nbsp;';
}
print '</td>';
// Contact
print '<td>';
if ($tab[$i]['source']=='internal')
{
$userstatic->id=$tab[$i]['id'];
$userstatic->lastname=$tab[$i]['lastname'];
$userstatic->firstname=$tab[$i]['firstname'];
print $userstatic->getNomUrl(1);
}
if ($tab[$i]['source']=='external')
{
$contactstatic->id=$tab[$i]['id'];
$contactstatic->lastname=$tab[$i]['lastname'];
$contactstatic->firstname=$tab[$i]['firstname'];
print $contactstatic->getNomUrl(1);
}
print '</td>';
// Type of contact
print '<td>'.$tab[$i]['libelle'].'</td>';
// Status
print '<td align="center">';
// Activate/Unactivate contact
if ($facture->statut >= 0) print '<a href="contact.php?facid='.$facture->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print $contactstatic->LibStatut($tab[$i]['status'],3);
if ($facture->statut >= 0) print '</a>';
print '</td>';
// Icon update et delete
print '<td align="center" nowrap>';
if ($user->rights->facture->creer)
{
print '&nbsp;';
print '<a href="contact.php?facid='.$facture->id.'&amp;action=deleteline&amp;lineid='.$tab[$i]['rowid'].'">';
print img_delete();
print '</a>';
}
print '</td>';
print "</tr>\n";
$i ++;
}
}
print "</table>";
print '<br>';
// Contacts lines
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
}
else
{
@ -356,7 +178,7 @@ if ($id > 0 || ! empty($ref))
}
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.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
@ -27,64 +28,42 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
if (!$user->rights->facture->lire)
accessforbidden();
$langs->load("companies");
$langs->load("bills");
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha');
$socid=GETPOST('socid','int');
$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$socid = $user->societe_id;
}
$socid=0;
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'facture',$id,'');
$fac = new Facture($db);
$fac->fetch($_GET["facid"]);
$object = new Facture($db);
$object->fetch($id);
/******************************************************************************/
/* Actions */
/******************************************************************************/
if ($_POST["action"] == 'update_public' && $user->rights->facture->creer)
if ($action == 'setnote_public' && $user->rights->facture->creer)
{
$db->begin();
$res=$fac->update_note_public($_POST["note_public"],$user);
if ($res < 0)
{
$mesg='<div class="error">'.$fac->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
$object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
if ($_POST["action"] == 'update' && $user->rights->facture->creer)
else if ($action == 'setnote' && $user->rights->facture->creer)
{
$db->begin();
$res=$fac->update_note($_POST["note"],$user);
if ($res < 0)
{
$mesg='<div class="error">'.$fac->error.'</div>';
$db->rollback();
}
else
{
$db->commit();
}
$object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
/******************************************************************************/
/* Affichage fiche */
/******************************************************************************/
@ -93,28 +72,26 @@ llxHeader();
$form = new Form($db);
$id = $_GET['facid'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
$fac = new Facture($db);
$fac->fetch($id,$ref);
$object = new Facture($db);
$object->fetch($id,$ref);
$soc = new Societe($db);
$soc->fetch($fac->socid);
$soc->fetch($object->socid);
$head = facture_prepare_head($fac);
$head = facture_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), 0, 'bill');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans('Ref').'</td>';
print '<tr><td width="25%">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">';
$morehtmlref='';
$discount=new DiscountAbsolute($db);
$result=$discount->fetch(0,$fac->id);
$result=$discount->fetch(0,$object->id);
if ($result > 0)
{
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
@ -123,72 +100,24 @@ if ($id > 0 || ! empty($ref))
{
dol_print_error('',$discount->error);
}
print $form->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref);
print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref);
print '</td></tr>';
// Company
print '<tr><td>'.$langs->trans("Company").'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1,'compta').'</td>';
// Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?facid='.$fac->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_public">';
print '<textarea name="note_public" cols="80" rows="8">'.$fac->note_public."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($fac->note_public?nl2br($fac->note_public):"&nbsp;");
}
print "</td></tr>";
// Note priv<69>e
if (! $user->societe_id)
{
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="note.php?facid='.$fac->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<textarea name="note" cols="80" rows="8">'.$fac->note."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>';
}
else
{
print ($fac->note?nl2br($fac->note):"&nbsp;");
}
print "</td></tr>";
}
print "</table>";
print '<br>';
/*
* Actions
*/
print '</div>';
print '<div class="tabsAction">';
if ($user->rights->facture->creer && $_GET["action"] <> 'edit')
{
print "<a class=\"butAction\" href=\"note.php?facid=$fac->id&amp;action=edit\">".$langs->trans('Modify')."</a>";
}
print "</div>";
include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
dol_fiche_end();
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -29,7 +29,7 @@ echo '<br>';
if ($num > 1) print_titre($langs->trans("RelatedBills"));
else print_titre($langs->trans("RelatedBill"));
?>
<table class="noborder" width="100%">
<table class="noborder allwidth">
<tr class="liste_titre">
<td><?php echo $langs->trans("Ref"); ?></td>
<td align="center"><?php echo $langs->trans("Date"); ?></td>

View File

@ -64,7 +64,7 @@ class localtax extends CommonObject
global $conf, $langs;
$error=0;
// Clean parameters
$this->amount=trim($this->amount);
$this->label=trim($this->label);
@ -131,7 +131,7 @@ class localtax extends CommonObject
global $conf, $langs;
$error=0;
// Clean parameters
$this->amount=trim($this->amount);
$this->label=trim($this->label);
@ -250,7 +250,7 @@ class localtax extends CommonObject
global $conf, $langs;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax";
$sql.= " WHERE rowid=".$this->id;
@ -300,6 +300,8 @@ class localtax extends CommonObject
/**
* Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de localtax, non ?
*
* @param int $year Year
* @return int ???
*/
function solde($year = 0)
{
@ -317,8 +319,9 @@ class localtax extends CommonObject
/**
* Total de la localtax des factures emises par la societe.
*
* @param int $year Year
* @return int ???
*/
function localtax_sum_collectee($year = 0)
{
@ -357,8 +360,9 @@ class localtax extends CommonObject
/**
* localtax payed
*
* @param int $year Year
* @return int ???
*/
function localtax_sum_payee($year = 0)
{
@ -398,8 +402,9 @@ class localtax extends CommonObject
* localtax payed
* Total de la localtax payed
*
* @param int $year Year
* @return int ???
*/
function localtax_sum_reglee($year = 0)
{

View File

@ -71,7 +71,7 @@ if ($socid)
}
$sql.= " AND p.statut = 0";
$sql.= " ORDER BY $sortfield $sortorder";
$sql.= $db->plimit($limit +1 ,$offset);
$sql.= $db->plimit($limit+1, $offset);
$resql = $db->query($sql);
if ($resql)
@ -96,7 +96,7 @@ if ($resql)
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.'<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td width="80" align="center">'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
print "<td>$objp->paiement_type $objp->num_paiement</td>\n";
print '<td align="right">'.price($objp->amount).'</td>';

View File

@ -72,7 +72,7 @@ class RemiseCheque extends CommonObject
$sql.= " WHERE bc.entity = ".$conf->entity;
if ($id) $sql.= " AND bc.rowid = ".$id;
if ($ref) $sql.= " AND bc.number = '".$this->db->escape($ref)."'";
dol_syslog("RemiseCheque::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
@ -113,13 +113,13 @@ class RemiseCheque extends CommonObject
/**
* Create a receipt to send cheques
*
* @param user User making creation
* @param account_id Bank account for cheque receipt
* @param limit Limit number of cheque to this
* @param toRemise array with cheques to remise
* @return int <0 if KO, >0 if OK
* @param User $user User making creation
* @param int $account_id Bank account for cheque receipt
* @param int $limit Limit number of cheque to this
* @param array $toRemise array with cheques to remise
* @return int <0 if KO, >0 if OK
*/
function create($user, $account_id, $limit=40,$toRemise)
function create($user, $account_id, $limit=40, $toRemise)
{
global $conf;
@ -271,7 +271,8 @@ class RemiseCheque extends CommonObject
/**
* Supprime la remise en base
*
* @param user utilisateur qui effectue l'operation
* @param User $user Utilisateur qui effectue l'operation
* @return void
*/
function delete($user='')
{
@ -326,8 +327,8 @@ class RemiseCheque extends CommonObject
/**
* Validate a receipt
*
* @param user User
* @return int <0 if KO, >0 if OK
* @param User $user User
* @return int <0 if KO, >0 if OK
*/
function validate($user)
{
@ -472,11 +473,11 @@ class RemiseCheque extends CommonObject
/**
* Build document
*
* @param model Model name
* @param outputlangs Object langs
* @return int <0 if KO, >0 if OK
* @param string $model Model name
* @param Tranlsate $outputlangs Object langs
* @return int <0 if KO, >0 if OK
*/
function generatePdf($model='blochet', $outputlangs)
function generatePdf($model, $outputlangs)
{
global $langs,$conf;
@ -555,8 +556,9 @@ class RemiseCheque extends CommonObject
}
/**
* \brief Mets a jour le montant total
* \return int 0 en cas de succes
* Mets a jour le montant total
*
* @return int 0 en cas de succes
*/
function updateAmount()
{
@ -614,9 +616,10 @@ class RemiseCheque extends CommonObject
}
/**
* \brief Insere la remise en base
* \param account_id Compte bancaire concerne
* \return int
* Insere la remise en base
*
* @param int $account_id Compte bancaire concerne
* @return int
*/
function removeCheck($account_id)
{
@ -643,8 +646,9 @@ class RemiseCheque extends CommonObject
return 0;
}
/**
* \brief Charge les proprietes ref_previous et ref_next
* \return int <0 si ko, 0 si ok
* Charge les proprietes ref_previous et ref_next
*
* @return int <0 if KO, 0 if OK
*/
function load_previous_next_id()
{
@ -684,9 +688,10 @@ class RemiseCheque extends CommonObject
/**
* Set the creation date
* @param user Object user
* @param date Date creation
* @return int <0 if KO, >0 if OK
*
* @param User $user Object user
* @param timestamp $date Date creation
* @return int <0 if KO, >0 if OK
*/
function set_date($user, $date)
{
@ -719,9 +724,10 @@ class RemiseCheque extends CommonObject
/**
* Renvoie nom clicable (avec eventuellement le picto)
* @param withpicto Inclut le picto dans le lien
* @param option Sur quoi pointe le lien
* @return string Chaine avec URL
*
* @param int $withpicto Inclut le picto dans le lien
* @param string $option Sur quoi pointe le lien
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
@ -741,9 +747,10 @@ class RemiseCheque extends CommonObject
}
/**
* \brief Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* \return string Libelle
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
*/
function getLibStatut($mode=0)
{
@ -751,10 +758,11 @@ class RemiseCheque extends CommonObject
}
/**
* Return label of a status
* @param status Statut
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
* Return label of a status
*
* @param int $status Statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
function LibStatut($status,$mode=0)
{

View File

@ -44,7 +44,7 @@ $accountstatic=new Account($db);
llxHeader('',$langs->trans("ChequesArea"));
print_fiche_titre($langs->trans("ChequesArea") );
print_fiche_titre($langs->trans("ChequesArea"));
print '<table border="0" width="100%" class="notopnoleftnoright">';

View File

@ -66,7 +66,7 @@ if ($_GET["search_montant"])
$sql.=" AND bc.amount=".price2num($_GET["search_montant"]);
}
$sql.= " ORDER BY $sortfield $sortorder";
$sql.= $db->plimit($limit+1 ,$offset);
$sql.= $db->plimit($limit+1, $offset);
//print "$sql";
$resql = $db->query($sql);

View File

@ -32,14 +32,16 @@ $langs->load("categories");
/**
* Replace the default llxHeader function
* @param $head
* @param $title
* @param $help_url
* @param $target
* @param $disablejs
* @param $disablehead
* @param $arrayofjs
* @param $arrayofcss
*
* @param string $head Optionnal head lines
* @param string $title HTML title
* @param string $help_url Link to online url help to show on left menu
* @param string $target Force target on menu links
* @param int $disablejs More content into html header
* @param int $disablehead More content into html header
* @param array $arrayofjs Array of complementary js files
* @param array $arrayofcss Array of complementary css files
* @return none
*/
function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
{

View File

@ -115,7 +115,7 @@ else
if ($_REQUEST["search_company"]) $sql .=" AND s.nom LIKE '%".$db->escape($_REQUEST["search_company"])."%'";
}
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1 ,$offset);
$sql.= $db->plimit($limit+1, $offset);
//print "$sql";
$resql = $db->query($sql);

View File

@ -28,6 +28,7 @@ require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php");
$langs->load("widthdrawals");
$langs->load("companies");
@ -80,7 +81,6 @@ $bprev = new BonPrelevement($db);
llxHeader('', $langs->trans("NewStandingOrder"));
require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php");
if (prelevement_check_config() < 0)
{
$langs->load("errors");

View File

@ -27,6 +27,7 @@ require("../bank/pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php");
$langs->load("withdrawals");
$langs->load("categories");
@ -49,7 +50,6 @@ $result = restrictedArea($user, 'prelevement','','');
llxHeader('',$langs->trans("CustomersStandingOrdersArea"));
require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php");
if (prelevement_check_config() < 0)
{
$langs->load("errors");

View File

@ -75,7 +75,7 @@ class Tva extends CommonObject
global $conf, $langs;
$error=0;
// Clean parameters
$this->amount=trim($this->amount);
$this->label=trim($this->label);
@ -147,7 +147,7 @@ class Tva extends CommonObject
global $conf, $langs;
$error=0;
// Clean parameters
$this->amount=trim($this->amount);
$this->label=trim($this->label);
@ -273,7 +273,7 @@ class Tva extends CommonObject
global $conf, $langs;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
$sql.= " WHERE rowid=".$this->id;
@ -460,9 +460,10 @@ class Tva extends CommonObject
/**
* \brief Ajoute un paiement de TVA
* \param user Object user that insert
* \return int <0 if KO, rowid in tva table if OK
* Ajoute un paiement de TVA
*
* @param User $user Object user that insert
* @return int <0 if KO, rowid in tva table if OK
*/
function addPayment($user)
{
@ -572,9 +573,10 @@ class Tva extends CommonObject
}
/**
* \brief Mise a jour du lien entre le paiement tva et la ligne g<EFBFBD>n<EFBFBD>r<EFBFBD>e dans llx_bank
* \param id_bank Id compte bancaire
* \return int <0 if KO, >0 if OK
* Mise a jour du lien entre le paiement tva et la ligne g<EFBFBD>n<EFBFBD>r<EFBFBD>e dans llx_bank
*
* @param int $id_bank Id compte bancaire
* @return int <0 if KO, >0 if OK
*/
function update_fk_bank($id_bank)
{
@ -594,11 +596,12 @@ class Tva extends CommonObject
/**
\brief Renvoie nom clicable (avec eventuellement le picto)
\param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
\param option Sur quoi pointe le lien
\return string Chaine avec URL
*/
* Renvoie nom clicable (avec eventuellement le picto)
*
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param string $option Sur quoi pointe le lien
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
global $langs;

View File

@ -51,9 +51,10 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
* to report the amounts for different VAT rates as different lines.
* This function also accounts recurrent invoices.
*
* @param db Database handler
* @param y Year
* @param q Year quarter (1-4)
* @param DoliDB $db Database handler
* @param int $y Year
* @param int $q Year quarter (1-4)
* @return void
*/
function tva_coll($db,$y,$q)
{
@ -118,9 +119,10 @@ function tva_coll($db,$y,$q)
* The function gets the VAT in split results, as the VAT declaration asks
* to report the amounts for different VAT rates as different lines
*
* @param DoliDB $db Database handler object
* @param int $y Year
* @param int $q Year quarter (1-4)
* @param DoliDB $db Database handler object
* @param int $y Year
* @param int $q Year quarter (1-4)
* @return void
*/
function tva_paye($db, $y,$q)
{
@ -289,16 +291,16 @@ if ($conf->global->COMPTA_MODE == "CREANCES-DETTES")
$i++;
}
print '<tr class="liste_total">' .
'<td align="right">'.$langs->trans("Total").':</td>' .
'<td nowrap align="right">'.price($subtot_coll_total).'</td>' .
'<td nowrap align="right">'.price($subtot_coll_vat).'</td>' .
'<td></td>' .
'<td nowrap align="right">'.price($subtot_paye_total).'</td>' .
'<td nowrap align="right">'.price($subtot_paye_vat).'</td>' .
'<td></td>' .
'<td nowrap align="right"><b>'.price($total).'</b>' .
'</td>';
print '<tr class="liste_total">';
print '<td align="right">'.$langs->trans("Total").':</td>';
print '<td nowrap="nowrap" align="right">'.price($subtot_coll_total).'</td>';
print '<td nowrap="nowrap" align="right">'.price($subtot_coll_vat).'</td>';
print '<td></td>';
print '<td nowrap="nowrap" align="right">'.price($subtot_paye_total).'</td>';
print '<td nowrap="nowrap" align="right">'.price($subtot_paye_vat).'</td>';
print '<td></td>';
print '<td nowrap="nowrap" align="right"><b>'.price($total).'</b>';
print '</td>';
print '</tr>';
}

View File

@ -70,8 +70,8 @@ abstract class ActionsContactCardCommon
/**
* Get object
*
* @param int Object id
* @return object Object loaded
* @param int $id Object id
* @return object Object loaded
*/
function getObject($id)
{
@ -226,8 +226,8 @@ abstract class ActionsContactCardCommon
/**
* Set content of ->tpl array, to use into template
*
* @param string $action Type of action
* @return string HTML output
* @param string &$action Type of action
* @return string HTML output
*/
function assign_values(&$action)
{

View File

@ -52,9 +52,12 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->canvas = $canvas;
$this->card = $card;
}
/**
* Return the title of card
*
* @param string $action Code action
* @return string Title
*/
private function getTitle($action)
{
@ -62,24 +65,25 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$out='';
if ($action == 'view') $out.= $langs->trans("Contact");
if ($action == 'edit') $out.= $langs->trans("EditContact");
if ($action == 'create') $out.= $langs->trans("NewContact");
if ($action == 'view') $out.= (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contact") : $langs->trans("ContactAddress"));
if ($action == 'edit') $out.= (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("EditContact") : $langs->trans("EditContactAddress"));
if ($action == 'create') $out.= (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
return $out;
}
/**
* Assign custom values for canvas
*
* @param string $action Type of action
* @return void
* @param string &$action Type of action
* @param int $id Id
* @return void
*/
function assign_values(&$action, $id)
{
global $conf, $db, $langs, $user;
global $form;
$ret = $this->getObject($id);
parent::assign_values($action);

View File

@ -36,7 +36,7 @@ echo $this->control->tpl['ajax_selectcountry']; ?>
<input type="hidden" name="socid" value="<?php echo $this->control->tpl['company_id']; ?>">
<?php } ?>
<table class="border" width="100%">
<table class="border allwidth">
<tr>
<td width="15%" class="fieldrequired"><?php echo $langs->trans("Lastname").' / '.$langs->trans("Label"); ?></td>

View File

@ -44,7 +44,7 @@ echo $this->control->tpl['ajax_selectcountry'];
<input type="hidden" name="socid" value="<?php echo $this->control->tpl['company_id']; ?>">
<?php } ?>
<table class="border" width="100%">
<table class="border allwidth">
<tr>
<td><?php echo $langs->trans("Ref"); ?></td>

View File

@ -29,7 +29,7 @@ dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']
<?php if ($this->control->tpl['action_create_user']) echo $this->control->tpl['action_create_user']; ?>
<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
<table class="border" width="100%">
<table class="border allwidth">
<tr>
<td width="20%"><?php echo $langs->trans("Ref"); ?></td>

View File

@ -130,7 +130,7 @@ if (empty($reshook))
if ($canvas) $object->canvas=$canvas;
$object->socid = $_POST["socid"];
$object->name = $_POST["name"];
$object->lastname = $_POST["lastname"];
$object->firstname = $_POST["firstname"];
$object->civilite_id = $_POST["civilite_id"];
$object->poste = $_POST["poste"];
@ -154,13 +154,13 @@ if (empty($reshook))
$object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
$object->birthday_alert = $_POST["birthday_alert"];
if (! $_POST["name"])
if (! $_POST["lastname"])
{
$error++; $errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"));
$action = 'create';
}
if ($_POST["name"])
if (! $error)
{
$id = $object->create($user);
if ($id <= 0)
@ -205,13 +205,13 @@ if (empty($reshook))
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
{
if (empty($_POST["name"]))
if (empty($_POST["lastname"]))
{
$error++; $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
$action = 'edit';
}
if (! count($errors))
if (! $error)
{
$object->fetch($_POST["contactid"]);
@ -221,7 +221,7 @@ if (empty($reshook))
$object->old_firstname = $_POST["old_firstname"];
$object->socid = $_POST["socid"];
$object->name = $_POST["name"];
$object->lastname = $_POST["lastname"];
$object->firstname = $_POST["firstname"];
$object->civilite_id = $_POST["civilite_id"];
$object->poste = $_POST["poste"];
@ -325,7 +325,8 @@ else
// Show tabs
$head = contact_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("ContactsAddresses"), 0, 'contact');
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
dol_fiche_head($head, 'card', $title, 0, 'contact');
}
if ($user->rights->societe->contact->creer)
@ -350,7 +351,8 @@ else
$object->country = $tmparray['label'];
}
print_fiche_titre($langs->trans("AddContact"));
$title = $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress"));
print_fiche_titre($title);
// Affiche les erreurs
dol_htmloutput_errors($error,$errors);
@ -375,7 +377,7 @@ else
print '<table class="border" width="100%">';
// Name
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%"><input name="name" type="text" size="30" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$object->name).'"></td>';
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%"><input name="lastname" type="text" size="30" maxlength="80" value="'.(isset($_POST["lastname"])?$_POST["lastname"]:$object->lastname).'"></td>';
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%"><input name="firstname" type="text" size="30" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td></tr>';
// Company
@ -556,7 +558,7 @@ else
print '</td></tr>';
// Name
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%"><input name="name" type="text" size="20" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$object->name).'"></td>';
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%"><input name="lastname" type="text" size="20" maxlength="80" value="'.(isset($_POST["lastname"])?$_POST["lastname"]:$object->lastname).'"></td>';
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%"><input name="firstname" type="text" size="20" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td></tr>';
// Company
@ -574,7 +576,7 @@ else
print $formcompany->select_civility(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id);
print '</td></tr>';
print '<tr><td>'.$langs->trans("PostOrFunction" ).'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.(isset($_POST["poste"])?$_POST["poste"]:$object->poste).'"></td></tr>';
print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.(isset($_POST["poste"])?$_POST["poste"]:$object->poste).'"></td></tr>';
// Address
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><textarea class="flat" name="address" cols="70">'.(isset($_POST["address"])?$_POST["address"]:$object->address).'</textarea></td>';
@ -735,7 +737,7 @@ else
print '</td></tr>';
// Name
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->name.'</td>';
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
// Company
@ -760,7 +762,7 @@ else
print '</td></tr>';
// Role
print '<tr><td>'.$langs->trans("PostOrFunction" ).'</td><td colspan="3">'.$object->poste.'</td>';
print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3">'.$object->poste.'</td>';
// Address
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">';

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