Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-02-08 00:22:58 +01:00
commit 842fb07d08
33 changed files with 253 additions and 137 deletions

View File

@ -771,7 +771,7 @@ if ($action == 'create')
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -992,7 +992,7 @@ if ($action == 'edit')
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -1304,7 +1304,7 @@ if ($rowid && $action != 'edit')
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('showOutputField',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{

View File

@ -243,7 +243,7 @@ if ($action == 'create')
// Other attributes
$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{

View File

@ -73,7 +73,7 @@ if (isset($socid))
{
$objectid=$socid;
$module='societe';
$dbtable='';
$dbtable='&societe';
}
else if (isset($id) && $id > 0)
{
@ -1471,7 +1471,7 @@ if ($id > 0 || ! empty($ref))
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{

View File

@ -2320,38 +2320,26 @@ class Commande extends CommonObject
dol_syslog("Commande::delete sql=".$sql);
if (! $this->db->query($sql) )
{
dol_syslog("CustomerOrder::delete error", LOG_ERR);
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("Commande::delete sql=".$sql);
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql) )
{
dol_syslog("CustomerOrder::delete error", LOG_ERR);
dol_syslog(get_class($this)."::delete error", LOG_ERR);
$error++;
}
// Delete linked object
// TODO deplacer dans le common
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
$sql.= " WHERE fk_target = ".$this->id;
$sql.= " AND targettype = '".$this->element."'";
dol_syslog("Commande::delete sql=".$sql);
if (! $this->db->query($sql) )
{
dol_syslog("CustomerOrder::delete error", LOG_ERR);
$error++;
}
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
// Delete linked contacts
$res = $this->delete_linked_contact();
if ($res < 0)
{
dol_syslog("CustomerOrder::delete error", LOG_ERR);
$error++;
}
if ($res < 0) $error++;
// On efface le repertoire de pdf provisoire
$comref = dol_sanitizeFileName($this->ref);
@ -2381,7 +2369,7 @@ class Commande extends CommonObject
}
}
if ($error == 0)
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");

View File

@ -1369,7 +1369,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -1921,7 +1921,7 @@ else
// Other attributes
$parameters=array('colspan' => ' colspan="2"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{

View File

@ -179,7 +179,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes')
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);
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
if ($result >= 0)
{
@ -360,7 +360,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
}
else
@ -437,7 +437,7 @@ if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
}
}
@ -1098,7 +1098,7 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
unset($_POST['qty']);
unset($_POST['type']);
@ -1200,7 +1200,7 @@ if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save']
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$ret=$object->fetch($id); // Reload to get new records
facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
}
}
}
@ -1229,7 +1229,7 @@ if ($action == 'up' && $user->rights->facture->creer)
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']);
exit;
@ -1251,7 +1251,7 @@ if ($action == 'down' && $user->rights->facture->creer)
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']);
exit;
@ -1485,7 +1485,7 @@ if (GETPOST('action') == 'builddoc') // En get ou en post
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$result=facture_pdf_create($db, $object, '', $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
$result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0)
{
dol_print_error($db,$result);
@ -1804,7 +1804,7 @@ if ($action == 'create')
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -2713,7 +2713,7 @@ else
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -3057,7 +3057,7 @@ 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, $_REQUEST['model'], $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
if ($result <= 0)
{
dol_print_error($db,$result);

View File

@ -1130,12 +1130,12 @@ class Facture extends CommonObject
$error=0;
$this->db->begin();
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
$sql.= " WHERE fk_target = ".$rowid;
$sql.= " AND targettype = '".$this->element."'";
if ($this->db->query($sql))
if (! $error)
{
// If invoice was converted into a discount not yet consumed, we remove discount
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'societe_remise_except';
@ -1188,7 +1188,7 @@ class Facture extends CommonObject
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->error=$this->db->lasterror()." sql=".$sql;
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback();
return -6;
@ -1196,7 +1196,7 @@ class Facture extends CommonObject
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->error=$this->db->lasterror()." sql=".$sql;
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback();
return -4;
@ -1204,7 +1204,7 @@ class Facture extends CommonObject
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;

View File

@ -112,7 +112,7 @@ if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights-
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
}
Header('Location: fiche.php?id='.$paiement->id);

View File

@ -94,7 +94,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' &&
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs, $hookmanager);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager);
}
Header('Location: fiche.php?id='.$paiement->id);

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2011-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
@ -134,6 +134,14 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
if (! $error)
{
if (! is_object($object)) $object = new GenericObject($db);
// Specific for add_object_linked()
// TODO add a function for variable treatment
$object->ext_fk_element = $newvalue;
$object->ext_element = $ext_element;
$object->fk_element = $fk_element;
$object->element = $element;
$ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format);
if ($ret > 0)
{

View File

@ -294,7 +294,7 @@ abstract class CommonObject
$sql.= " WHERE element_id =".$this->id;
$sql.= " AND fk_c_type_contact IN (".$listId.")";
dol_syslog(get_class($this)."::delete_linked_contact sql=".$sql);
dol_syslog(get_class($this)."::delete_linked_contact sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
return 1;
@ -1514,10 +1514,10 @@ abstract class CommonObject
if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $justsource=true;
if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $justtarget=true;
$sourceid = (! empty($sourceid) ? $sourceid : $this->id );
$targetid = (! empty($targetid) ? $targetid : $this->id );
$sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element ) );
$targettype = (! empty($targettype) ? $targettype : $this->element );
$sourceid = (! empty($sourceid) ? $sourceid : $this->id);
$targetid = (! empty($targetid) ? $targetid : $this->id);
$sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element));
$targettype = (! empty($targettype) ? $targettype : $this->element);
// Links beetween objects are stored in this table
$sql = 'SELECT fk_source, sourcetype, fk_target, targettype';
@ -1629,7 +1629,77 @@ abstract class CommonObject
dol_print_error($this->db);
}
}
/**
* Update object linked of a current object
*
* @param int $sourceid Object source id
* @param string $sourcetype Object source type
* @param int $targetid Object target id
* @param string $targettype Object target type
* @return int >0 if OK, <0 if KO
*/
function updateObjectLinked($sourceid='', $sourcetype='', $targetid='', $targettype='')
{
$updatesource=false;
$updatetarget=false;
if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource=true;
else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $updatetarget=true;
$sql = "UPDATE ".MAIN_DB_PREFIX."element_element SET ";
if ($updatesource)
{
$sql.= "fk_source = ".$sourceid;
$sql.= ", sourcetype = '".$sourcetype."'";
$sql.= " WHERE fk_target = ".$this->id;
$sql.= " AND targettype = '".$this->element."'";
}
else if ($updatetarget)
{
$sql.= "fk_target = ".$targetid;
$sql.= ", targettype = '".$targettype."'";
$sql.= " WHERE fk_source = ".$this->id;
$sql.= " AND sourcetype = '".$this->element."'";
}
dol_syslog(get_class($this)."::updateObjectLinked sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
return 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::updateObjectLinked error=".$this->error, LOG_ERR);
return -1;
}
}
/**
* Delete all links between an object $this
*
* @return int >0 if OK, <0 if KO
*/
function deleteObjectLinked()
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
$sql.= " WHERE fk_target = ".$this->id;
$sql.= " AND targettype = '".$this->element."'";
dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
return 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::deleteObjectLinked error=".$this->error, LOG_ERR);
return -1;
}
}
/**
* Set statut of an object
*
@ -1787,6 +1857,8 @@ abstract class CommonObject
{
global $langs;
$error=0;
if (count($this->array_options) > 0)
{
// Check parameters
@ -2045,19 +2117,19 @@ abstract class CommonObject
if ($objecttype == 'facture') {
$tplpath = 'compta/'.$element;
}
if ($objecttype == 'propal') {
else if ($objecttype == 'propal') {
$tplpath = 'comm/'.$element;
}
if ($objecttype == 'shipping') {
else if ($objecttype == 'shipping') {
$tplpath = 'expedition';
}
if ($objecttype == 'delivery') {
else if ($objecttype == 'delivery') {
$tplpath = 'livraison';
}
if ($objecttype == 'invoice_supplier') {
else if ($objecttype == 'invoice_supplier') {
$tplpath = 'fourn/facture';
}
if ($objecttype == 'order_supplier') {
else if ($objecttype == 'order_supplier') {
$tplpath = 'fourn/commande';
}

View File

@ -148,7 +148,7 @@ class HookManager
$var=!$var;
// Hooks that return int
if (($method == 'doActions' || $method='formObjectOptions') && method_exists($actioninstance,$method))
if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actioninstance,$method))
{
$resaction+=$actioninstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
if ($resaction < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && count($actioninstance->errors) > 0))

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (c) 2002-2007 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) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
@ -87,7 +87,6 @@ class Form
if ($perm)
{
$tmp=explode(':',$typeofdata);
if (preg_match('/^(string|email|numeric)$/i',$tmp[0])) $tmp[0] = 'text';
$ret.= '<div class="editkey_'.$tmp[0].'" id="'.$htmlname.'">';
$ret.= $langs->trans($text);
$ret.= '</div>'."\n";
@ -237,8 +236,7 @@ class Form
if (preg_match('/^(string|email|numeric)/',$inputType))
{
$tmp=explode(':',$inputType);
$inputType='text';
$inputOption=$tmp[1];
$inputType=$tmp[0]; $inputOption=$tmp[1];
if (! empty($tmp[2])) $savemethod=$tmp[2];
}
if (preg_match('/^datepicker/',$inputType))

View File

@ -107,7 +107,7 @@ $(document).ready(function() {
$( '#val_' + $(this).attr('id') ).click();
});
$('.editval_text').editable(urlSaveInPlace, {
$('.editval_string').editable(urlSaveInPlace, {
type : 'text',
id : 'field',
width : 300,
@ -118,7 +118,7 @@ $(document).ready(function() {
indicator : indicatorInPlace,
submitdata : function(result, settings) {
var htmlname = $(this).attr('id').substr(4);
return getParameters('text', htmlname);
return getParameters('string', htmlname);
},
callback : function(result, settings) {
var obj = $.parseJSON(result);
@ -131,7 +131,7 @@ $(document).ready(function() {
}
}
});
$('.editkey_text').hover(
$('.editkey_string').hover(
function () {
$( '#val_' + $(this).attr('id') ).addClass("editval_hover");
},
@ -139,7 +139,7 @@ $(document).ready(function() {
$( '#val_' + $(this).attr('id') ).removeClass("editval_hover");
}
);
$('.editkey_text').click(function() {
$('.editkey_string').click(function() {
$( '#val_' + $(this).attr('id') ).click();
});
@ -236,7 +236,7 @@ $(document).ready(function() {
},
callback : function(result, settings) {
var obj = $.parseJSON(result);
if (obj.error) {
$(this).html(this.revert);
$.jnotify(obj.error, "error", true);

View File

@ -1050,7 +1050,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
if ($usealternatemethod || $gm) // Si time gm, seule adodb peut convertir
{
$date=adodb_mktime($hour,$minute,$second,$month,$day,$year,$isdst,$gm);
$date=adodb_mktime($hour,$minute,$second,$month,$day,$year,0,$gm);
}
else
{

View File

@ -112,7 +112,7 @@ function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
else
{
$outputlangs->charset_output=$sav_charset_output;
dol_print_error($db,"facture_pdf_create Error: ".$obj->error);
dol_print_error($db,"chequereceipt_pdf_create Error: ".$obj->error);
return -1;
}

View File

@ -205,7 +205,7 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0
require_once($file);
$obj = new $classname($db);
$obj->message = $message;
//$obj->message = $message;
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.

View File

@ -130,12 +130,11 @@ abstract class ModeleNumRefFactures
/**
* Create a document onto disk accordign to template module.
* Create a document onto disk according to template module.
*
* @param DoliDB $db Database handler
* @param Object $object Object invoice
* @param string $message message
* @param string $modele Force le modele a utiliser ('' to not force)
* @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
@ -143,7 +142,7 @@ abstract class ModeleNumRefFactures
* @param HookManager $hookmanager Hook manager instance
* @return int <0 if KO, >0 if OK
*/
function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
{
global $conf,$user,$langs;
@ -204,7 +203,6 @@ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hide
require_once($file);
$obj = new $classname($db);
$obj->message = $message;
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.

View File

@ -155,7 +155,7 @@ class modWorkflow extends DolibarrModules
$sql = array();
return $this->_init($sql,$option);
return $this->_init($sql,$options);
}
/**

View File

@ -195,7 +195,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
require_once($file);
$obj = new $classname($db);
$obj->message = $message;
//$obj->message = $message;
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.

View File

@ -58,38 +58,69 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
*
* @param DoliDB $db objet base de donnee
* @param Object $object object supplier invoice
* @param string $model force le modele a utiliser ('' to not force)
* @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @return int 0 if KO, 1 if OK
*/
function supplier_invoice_pdf_create($db, $object, $model, $outputlangs)
function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs)
{
global $conf, $langs;
global $conf, $user, $langs;
$langs->load("suppliers");
$dir = DOL_DOCUMENT_ROOT."/core/modules/supplier_invoice/pdf/";
$error=0;
// Increase limit for PDF build
$err=error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
$dir = "/core/modules/supplier_invoice/";
$srctemplatepath='';
// Positionne modele sur le nom du modele de invoice fournisseur a utiliser
if (! dol_strlen($model))
if (! dol_strlen($modele))
{
if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF))
{
$model = $conf->global->INVOICE_SUPPLIER_ADDON_PDF;
$modele = $conf->global->INVOICE_SUPPLIER_ADDON_PDF;
}
else
{
$model = 'canelle';
//print $langs->trans("Error")." ".$langs->trans("Error_INVOICE_SUPPLIER_ADDON_PDF_NotDefined");
//return 0;
$modele = 'canelle';
}
}
// Charge le modele
$file = "pdf_".$model.".modules.php";
if (file_exists($dir.$file))
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp=explode(':',$modele,2);
if (! empty($tmp[1]))
{
$modele=$tmp[0];
$srctemplatepath=$tmp[1];
}
// Search template file
$file=''; $classname=''; $filefound=0;
foreach(array('doc','pdf') as $prefix)
{
$classname = "pdf_".$model;
require_once($dir.$file);
$file = $prefix."_".$modele.".modules.php";
// On verifie l'emplacement du modele
$file = dol_buildpath($dir.'pdf/'.$file); // TODO rename into doc/
if (file_exists($file))
{
$filefound=1;
$classname=$prefix.'_'.$modele;
break;
}
}
// Charge le modele
if ($filefound)
{
require_once($file);
$obj = new $classname($db,$object);
@ -103,6 +134,14 @@ function supplier_invoice_pdf_create($db, $object, $model, $outputlangs)
// we delete preview files
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
dol_delete_preview($object);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('BILL_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
return 1;
}
else
@ -115,7 +154,7 @@ function supplier_invoice_pdf_create($db, $object, $model, $outputlangs)
}
else
{
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file);
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
return 0;
}
}

View File

@ -303,6 +303,24 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4;
// Et si on affiche dates de validite, on ajoute encore une ligne
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
{
$nblineFollowDesc += 4;
}
}
else // If it's last line
{
$nblineFollowDesc = 0;
}
// Test if a new page is required
if ($pagenb == 1)
{

View File

@ -761,16 +761,16 @@ class Expedition extends CommonObject
if ( $this->db->query($sql) )
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
$sql.= " WHERE fk_target = ".$this->id;
$sql.= " AND targettype = '".$this->element."'";
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
if ( $this->db->query($sql) )
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition";
$sql.= " WHERE rowid = ".$this->id;
if ( $this->db->query($sql) )
if ($this->db->query($sql))
{
$this->db->commit();

View File

@ -585,16 +585,8 @@ class Fichinter extends CommonObject
$this->db->begin();
// Delete linked object
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
$sql.= " WHERE fk_target = ".$this->id;
$sql.= " AND targettype = '".$this->element."'";
dol_syslog("Fichinter::delete sql=".$sql);
if (! $this->db->query($sql) )
{
dol_syslog("Fichinter::delete error", LOG_ERR);
$this->error=$this->db->lasterror();
$error++;
}
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
// Delete linked contacts
$res = $this->delete_linked_contact();

View File

@ -549,15 +549,18 @@ class Livraison extends CommonObject
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$this->db->begin();
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet";
$sql.= " WHERE fk_livraison = ".$this->id;
if ( $this->db->query($sql) )
if ($this->db->query($sql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
$sql.= " WHERE fk_target = ".$this->id;
$sql.= " AND targettype = '".$this->element."'";
if ( $this->db->query($sql) )
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error++;
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison";
$sql.= " WHERE rowid = ".$this->id;

View File

@ -783,7 +783,7 @@ else
// Other attributes
$parameters=array('colspan' => ' colspan="2"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -987,7 +987,7 @@ else
// Other attributes
$parameters=array('colspan' => ' colspan="2"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -1214,7 +1214,7 @@ else
// Other attributes
$parameters=array('colspan' => ' colspan="2"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{

View File

@ -941,7 +941,7 @@ else
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -1369,7 +1369,7 @@ else
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{
@ -1718,7 +1718,7 @@ else
// Other attributes
$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key=>$label)
{

View File

@ -1652,7 +1652,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
/* jQuery - jeditable */
/* ============================================================================== */
.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select {
.editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select {
background: url(<?php echo dol_buildpath($path.'/theme/auguria/img/edit.png',1) ?>) right top no-repeat;
cursor: pointer;
}
@ -1662,7 +1662,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
cursor: pointer;
}
.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
.editval_textarea:hover, .editval_ckeditor:hover, .editval_string:hover, .editval_email:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
background: white;
cursor: pointer;
}

View File

@ -1844,7 +1844,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
/* jQuery - jeditable */
/* ============================================================================== */
.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select {
.editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select {
background: url(<?php echo dol_buildpath($path.'/theme/bureau2crea/img/edit.png',1) ?>) right top no-repeat;
cursor: pointer;
}
@ -1854,7 +1854,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
cursor: pointer;
}
.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
.editval_textarea:hover, .editval_ckeditor:hover, .editval_string:hover, .editval_email:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
background: white;
cursor: pointer;
}

View File

@ -1791,7 +1791,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
/* jQuery - jeditable */
/* ============================================================================== */
.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select {
.editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select {
background: url(<?php echo dol_buildpath($path.'/theme/cameleo/img/edit.png',1) ?>) right top no-repeat;
cursor: pointer;
}
@ -1801,7 +1801,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
cursor: pointer;
}
.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
.editval_textarea:hover, .editval_ckeditor:hover, .editval_string:hover, .editval_email:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
background: white;
cursor: pointer;
}

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
/* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007-2012 Regis Houssin <regis@dolibarr.fr>
* 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
@ -1959,7 +1959,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
/* jQuery - jeditable */
/* ============================================================================== */
.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select {
.editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select {
background: url(<?php echo dol_buildpath($path.'/theme/eldy/img/edit.png',1) ?>) right top no-repeat;
cursor: pointer;
}
@ -1969,7 +1969,7 @@ table.cal_event td { border: 0px; padding-<?php print $left; ?>: 0px; padding-<?
cursor: pointer;
}
.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
.editval_textarea:hover, .editval_ckeditor:hover, .editval_string:hover, .editval_email:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover {
background: white;
cursor: pointer;
}

View File

@ -270,7 +270,7 @@ if ( $resql=$db->query($sql) )
}
}
print "Build PDF for invoice ".$obj->facnumber." - Lang = ".$outputlangs->defaultlang."\n";
$result=facture_pdf_create($db, $fac, '', $newmodel?$newmodel:$fac->modelpdf, $outputlangs);
$result=facture_pdf_create($db, $fac, $newmodel?$newmodel:$fac->modelpdf, $outputlangs);
// Add file into files array
$files[] = $conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';

View File

@ -162,14 +162,14 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
// Crabe
$localobject->modelpdf='crabe';
$result=facture_pdf_create($db, $localobject, '', $localobject->modelpdf, $langs);
$result=facture_pdf_create($db, $localobject, $localobject->modelpdf, $langs);
$this->assertLessThan($result, 0);
print __METHOD__." result=".$result."\n";
// Oursin
$localobject->modelpdf='oursin';
$result=facture_pdf_create($db, $localobject, '', $localobject->modelpdf, $langs);
$result=facture_pdf_create($db, $localobject, $localobject->modelpdf, $langs);
$this->assertLessThan($result, 0);
print __METHOD__." result=".$result."\n";