develop

Conflicts:
	htdocs/install/mysql/migration/3.3.0-3.4.0.sql

Change-Id: I9df271d1629014299e7db131a66c1322aa897f6d
This commit is contained in:
fhenry 2013-04-07 23:52:02 +02:00
commit 393007625a
28 changed files with 256 additions and 186 deletions

View File

@ -2,7 +2,7 @@
English Dolibarr ChangeLog
--------------------------------------------------------------
***** ChangeLog for 3.4 compared to 3.3 *****
***** ChangeLog for 3.4 compared to 3.3.2 *****
For users:
- New: Support revenue stamp onto invoices.
- New: Add a tab "consumption" on thirdparties to list products bought/sells.
@ -64,6 +64,19 @@ WARNING: If you used external modules, some of them may need to be upgraded due
***** ChangeLog for 3.3.2 compared to 3.3.1 *****
- Fix: Ducth (nl_NL) translation
- Fix: [ bug #790 ] Spanish localtax RE not being correctly calculated
- Generalize fix: file with a specific mask not found, again
- Fix: translations and BILL_SUPPLIER_BUILDDOC trigger
- Fix: Can't reset payment due date
- Fix: [ bug #787 ] Invoice supplier box incorrect tooltip when delay on payment
- Fix: [ bug #794 ] Lost filter on zipcode in prospect list
- Fix: [ bug #774 ] Bug on creating event with box "all day" crossed
***** ChangeLog for 3.3.1 compared to 3.3 *****
- Fix: [ bug #733 ] Mass emailing tools do not support <style HTML tag

View File

@ -1530,40 +1530,6 @@ class Adherent extends CommonObject
return $result;
}
/**
* 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
*/
function getFullAddress($withcountry=0,$sep="\n")
{
$ret='';
if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php';
$tmparray=getCountry($this->country_id,'all');
$this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
}
else
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
}
return trim($ret);
}
/**
* Retourne le libelle du statut d'un adherent (brouillon, valide, resilie)
*

View File

@ -161,7 +161,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
$sql.= " ORDER BY dlr ASC";
// Supplier invoices
$sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.facnumber as ref, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,";
$sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref_supplier as ref, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,";
$sql2.= " s.rowid as socid, s.nom, s.fournisseur";
$sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff";
$sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid";

View File

@ -102,9 +102,8 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye
if (! empty($conf->banque->enabled))
{
// Si module bank actif, un compte est obligatoire lors de la saisie
// d'un paiement
if (! $_POST['accountid'])
// If bank module is on, account is required to enter a payment
if (GETPOST('accountid') <= 0)
{
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>';
$error++;
@ -157,6 +156,16 @@ if ($action == 'confirm_paiement' && $confirm == 'yes')
}
}
if (! empty($conf->banque->enabled))
{
// Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement
if (GETPOST('accountid') <= 0)
{
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>';
$error++;
}
}
// Creation of payment line
$paiement = new Paiement($db);
$paiement->datepaye = $datepaye;
@ -179,7 +188,7 @@ if ($action == 'confirm_paiement' && $confirm == 'yes')
{
$label='(CustomerInvoicePayment)';
if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)';
$result=$paiement->addPaymentToBank($user,'payment',$label,$_POST['accountid'],$_POST['chqemetteur'],$_POST['chqbank']);
$result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),GETPOST('chqemetteur'),GETPOST('chqbank'));
if ($result < 0)
{
$errmsg=$paiement->error;
@ -471,7 +480,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
{
$sign=1;
if ($facture->type == 2) $sign=-1;
$arraytitle=$langs->trans('Invoice');
if ($facture->type == 2) $arraytitle=$langs->trans("CreditNotes");
$alreadypayedlabel=$langs->trans('Received');

View File

@ -366,7 +366,7 @@ class Paiement extends CommonObject
/**
* A record into bank for payment with links between this bank record and invoices of payment.
* Add a record into bank for payment with links between this bank record and invoices of payment.
* All payment properties (this->amount, this->amounts, ...) must have been set first like after a call to create().
*
* @param User $user Object of user making payment
@ -384,16 +384,26 @@ class Paiement extends CommonObject
$error=0;
$bank_line_id=0;
$this->fk_account=$accountid;
if (! empty($conf->banque->enabled))
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if ($accountid <= 0)
{
$this->error='Bad value for parameter accountid';
dol_syslog(get_class($this).'::addPaymentToBank '.$this->error, LOG_ERR);
return -1;
}
$this->db->begin();
$this->fk_account=$accountid;
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
dol_syslog("$user->id,$mode,$label,$this->fk_account,$emetteur_nom,$emetteur_banque");
$acc = new Account($this->db);
$acc->fetch($this->fk_account);
$result=$acc->fetch($this->fk_account);
$totalamount=$this->amount;
if (empty($totalamount)) $totalamount=$this->total; // For backward compatibility
@ -497,10 +507,19 @@ class Paiement extends CommonObject
}
}
else
{
{
$this->error=$acc->error;
$error++;
}
if (! $error)
{
$this->db->commit();
}
else
{
$this->db->rollback();
}
}
if (! $error)

View File

@ -866,41 +866,6 @@ class Contact extends CommonObject
return $result;
}
/**
* Return full address of contact
*
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @return string Full address string
*/
function getFullAddress($withcountry=0,$sep="\n")
{
$ret='';
if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php';
$tmparray=getCountry($this->country_id,'all');
$this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
}
else
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
}
return trim($ret);
}
/**
* Return label of a civility contact
*

View File

@ -78,6 +78,26 @@ abstract class CommonObject
return dol_trunc($ret,$maxlen);
}
/**
* Return full address of contact
*
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @return string Full address string
*/
function getFullAddress($withcountry=0,$sep="\n")
{
if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php';
$tmparray=getCountry($this->country_id,'all');
$this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
return dol_format_address($this, $withcountry, $sep);
}
/**
* Check if ref is used.
*
@ -1558,7 +1578,7 @@ abstract class CommonObject
// Add revenue stamp to total
$this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0;
$this->db->free($resql);
// Now update global field total_ht, total_ttc and tva
@ -2139,7 +2159,7 @@ abstract class CommonObject
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
break;
}
}
}
$this->db->begin();
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
@ -2189,27 +2209,27 @@ abstract class CommonObject
}
else return 0;
}
/**
* Function to show lines of extrafields with output datas
*
*
* @param object $extrafields extrafield Object
* @param string $mode Show output (view) or input (edit) for extrafield
*
* @return string
* @param string $mode Show output (view) or input (edit) for extrafield
*
* @return string
*/
function showOptionals($extrafields,$mode='view')
{
global $_POST;
$out = '';
if(count($extrafields->attribute_label) > 0)
{
$out .= "\n";
$out .= '<!-- showOptionalsInput --> ';
$out .= "\n";
$e = 0;
foreach($extrafields->attribute_label as $key=>$label)
{
@ -2226,7 +2246,7 @@ abstract class CommonObject
$out .= '<tr>';
$colspan='0';
}
else
else
{
$out .= '<tr>';
}
@ -2237,7 +2257,7 @@ abstract class CommonObject
}
$out .= '<td>'.$label.'</td>';
$out .='<td colspan="'.$colspan.'">';
switch($mode) {
case "view":
$out .= $extrafields->showOutputField($key,$value);
@ -2246,9 +2266,9 @@ abstract class CommonObject
$out .= $extrafields->showInputField($key,$value);
break;
}
$out .= '</td>'."\n";
if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
else $out .= '</tr>';
$e++;

View File

@ -675,19 +675,21 @@ function dol_get_fiche_end($notab=0)
* Return a formated address (part address/zip/town/state) according to country rules
*
* @param Object $object A company or contact object
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @return string Formated string
*/
function dol_format_address($object)
function dol_format_address($object,$withcountry=0,$sep="\n")
{
$ret='';
$countriesusingstate=array('US','IN','GB','ES');
$countriesusingstate=array('AU','US','IN','GB','ES');
// Address
$ret .= $object->address;
// Zip/Town/State
if (in_array($object->country_code,array('US'))) // US: title firstname name \n address lines \n town, state, zip \n country
if (in_array($object->country_code,array('US','AU'))) // US: title firstname name \n address lines \n town, state, zip \n country
{
$ret .= ($ret ? "\n" : '' ).$object->town;
$ret .= ($ret ? $sep : '' ).$object->town;
if ($object->state && in_array($object->country_code,$countriesusingstate))
{
$ret.=", ".$object->state;
@ -696,16 +698,16 @@ function dol_format_address($object)
}
else if (in_array($object->country_code,array('GB'))) // UK: title firstname name \n address lines \n town state \n zip \n country
{
$ret .= ($ret ? "\n" : '' ).$object->town;
$ret .= ($ret ? $sep : '' ).$object->town;
if ($object->state && in_array($object->country_code,$countriesusingstate))
{
$ret.=", ".$object->state;
}
if ($object->zip) $ret .= ($ret ? "\n" : '' ).$object->zip;
if ($object->zip) $ret .= ($ret ? $sep : '' ).$object->zip;
}
else if (in_array($object->country_code,array('ES'))) // title firstname name \n address lines \n zip town \n state \n country
else if (in_array($object->country_code,array('ES'))) // ES: title firstname name \n address lines \n zip town \n state \n country
{
$ret .= ($ret ? "\n" : '' ).$object->zip;
$ret .= ($ret ? $sep : '' ).$object->zip;
$ret .= ' '.$object->town;
if ($object->state && in_array($object->country_code,$countriesusingstate))
{
@ -715,7 +717,7 @@ function dol_format_address($object)
else // Other: title firstname name \n address lines \n zip town \n country
{
$ret .= ($ret ? "\n" : '' ).$object->zip;
$ret .= ($ret ? $sep : '' ).$object->zip;
$ret .= ' '.$object->town;
if ($object->state && in_array($object->country_code,$countriesusingstate))
{
@ -723,6 +725,8 @@ function dol_format_address($object)
}
}
if ($withcountry) $ret.=($object->country?$sep.$object->country:'');
return $ret;
}
@ -2752,18 +2756,18 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="")
// Some test to guess with no need to make database access
if ($mysoc->country_code == 'ES') // For spain localtaxes 1 and 2, tax is qualified if buyer use local taxe
{
if ($local == 1)
if ($local == 1)
{
if ($thirdparty_seller->id==$mysoc->id)
{
if (! $thirdparty_buyer->localtax1_assuj) return 0;
}
else
else
{
if (! $thirdparty_seller->localtax1_assuj) return 0;
}
}
if ($local == 2 && ! $thirdparty_buyer->localtax2_assuj) return 0;
}
else

View File

@ -672,7 +672,7 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
{
if (strlen(GETPOST('subject','alphs'))) $subject = GETPOST('subject','alpha');
else $subject = $langs->transnoentities('Intervention').' '.$object->ref;
$actiontypecode='AC_FICH';
$actiontypecode='AC_OTH_AUTO';
$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
if ($message)
{

View File

@ -147,7 +147,7 @@ class FactureFournisseur extends CommonInvoice
$sql.= ")";
$sql.= " VALUES (";
$sql.= "'(PROV)'";
$sql.= ", '".$this->db->escape($this->$ref_supplier)."'";
$sql.= ", '".$this->db->escape($this->ref_supplier)."'";
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->db->escape($this->libelle)."'";
$sql.= ", ".$this->socid;
@ -159,12 +159,19 @@ class FactureFournisseur extends CommonInvoice
$sql.= $this->date_echeance!=''?"'".$this->db->idate($this->date_echeance)."'":"null";
$sql.= ")";
dol_syslog("FactureFournisseur::create sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn');
// Update ref with new one
$this->ref='(PROV'.$this->id.')';
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture_fourn SET ref='".$this->ref."' WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::create sql=".$sql);
$resql=$this->db->query($sql);
if (! $resql) $error++;
// Add object linked
if (! $error && $this->id && ! empty($this->origin) && ! empty($this->origin_id))
@ -182,7 +189,7 @@ class FactureFournisseur extends CommonInvoice
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)';
$sql .= ' VALUES ('.$this->id.');';
dol_syslog("FactureFournisseur::create sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql_insert=$this->db->query($sql);
if ($resql_insert)
{
@ -1078,7 +1085,7 @@ class FactureFournisseur extends CommonInvoice
$pu_ttc = $tabprice[5];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
$info_bits = empty($info_bits) ? 0 : $info_bits;
if (empty($info_bits)) $info_bits=0;
if ($idproduct)
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley <marc@ocebo.fr>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
@ -1777,7 +1777,7 @@ else
print '</td>';
// VAT
print '<td align="right">'.vatrate($object->lines[$i]->tva_tx, true, $object->lines[$i]->info_bits).'%</td>';
print '<td align="right">'.vatrate($object->lines[$i]->tva_tx, true, $object->lines[$i]->info_bits).'</td>';
// Unit price
print '<td align="right" nowrap="nowrap">'.price($object->lines[$i]->pu_ht,'MU').'</td>';

View File

@ -255,14 +255,13 @@ if ($resql)
print '<td nowrap="nowrap">'.dol_trunc($obj->ref_supplier,10)."</td>";
print '<td align="center" nowrap="nowrap">'.dol_print_date($db->jdate($obj->datef),'day').'</td>';
print '<td align="center" nowrap="nowrap">'.dol_print_date($db->jdate($obj->date_echeance),'day');
if (($obj->paye == 0) && ($obj->fk_statut > 0) && $db->jdate($obj->date_echeance) < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
if (($obj->paye == 0) && ($obj->fk_statut > 0) && $obj->date_echeance && $db->jdate($obj->date_echeance) < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
print '</td>';
print '<td>'.dol_trunc($obj->libelle,36).'</td>';
print '<td>';
$supplierstatic->id=$obj->socid;
$supplierstatic->nom=$obj->nom;
print $supplierstatic->getNomUrl(1,'',12);
//print '<a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'</a</td>';
print '<td align="right">'.price($obj->total_ht).'</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>';
$total+=$obj->total_ht;

View File

@ -9,8 +9,9 @@ class SegmentException extends Exception
* Encoding : ISO-8859-1
*
* @copyright GPL License 2008 - Julien Pauli - Cyril PIERRE de GEYER - Anaska (http://www.anaska.com)
* @copyright GPL License 2012 - Stephen Larroque - lrq3000@gmail.com
* @license http://www.gnu.org/copyleft/gpl.html GPL License
* @version 1.3
* @version 1.4.5 (last update 2013-04-07)
*/
class Segment implements IteratorAggregate, Countable
{
@ -93,7 +94,10 @@ class Segment implements IteratorAggregate, Countable
$this->file->open($this->odf->getTmpfile());
foreach ($this->images as $imageKey => $imageValue) {
if ($this->file->getFromName('Pictures/' . $imageValue) === false) {
// Add the image inside the ODT document
$this->file->addFile($imageKey, 'Pictures/' . $imageValue);
// Add the image to the Manifest (which maintains a list of images, necessary to avoid "Corrupt ODT file. Repair?" when opening the file with LibreOffice)
$this->odf->addImageToManifest($imageValue);
}
}
$this->file->close();
@ -153,11 +157,16 @@ class Segment implements IteratorAggregate, Countable
if ($size === false) {
throw new OdfException("Invalid image");
}
// Set the width and height of the page
list ($width, $height) = $size;
$width *= Odf::PIXEL_TO_CM;
$height *= Odf::PIXEL_TO_CM;
// Fix local-aware issues (eg: 12,10 -> 12.10)
$width = sprintf("%F", $width);
$height = sprintf("%F", $height);
$xml = <<<IMG
<draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="char" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>
<draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="aschar" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>
IMG;
$this->images[$value] = $file;
$this->setVars($key, $xml, false);

View File

@ -1,4 +1,6 @@
<?php
require_once 'zip/PclZipProxy.php';
require_once 'zip/PhpZipProxy.php';
require 'Segment.php';
class OdfException extends Exception
{}
@ -10,8 +12,10 @@ class OdfException extends Exception
*
* @copyright GPL License 2008 - Julien Pauli - Cyril PIERRE de GEYER - Anaska (http://www.anaska.com)
* @copyright GPL License 2010 - Laurent Destailleur - eldy@users.sourceforge.net
* @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
* @copyright GPL License 2012 - Stephen Larroque - lrq3000@gmail.com
* @license http://www.gnu.org/copyleft/gpl.html GPL License
* @version 1.4.3 (last update 2012-07-29)
* @version 1.4.6 (last update 2013-04-07)
*/
class Odf
{
@ -82,7 +86,7 @@ class Odf
throw new OdfException("Nothing to parse - Check that the content.xml file is correctly formed in source file '$filename'");
}
if (($this->manifestXml = $this->file->getFromName('META-INF/manifest.xml')) === false) {
throw new OdfException("Something is wrong with META-INF/manifest.xm in source file '$filename'");
throw new OdfException("Something is wrong with META-INF/manifest.xml in source file '$filename'");
}
if (($this->stylesXml = $this->file->getFromName('styles.xml')) === false) {
throw new OdfException("Nothing to parse - Check that the styles.xml file is correctly formed in source file '$filename'");
@ -110,21 +114,46 @@ class Odf
*/
public function setVars($key, $value, $encode = true, $charset = 'ISO-8859')
{
$tag = $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT'];
// TODO Warning string may be:
// <text:span text:style-name="T13">{</text:span><text:span text:style-name="T12">aaa</text:span><text:span text:style-name="T13">}</text:span>
// instead of {aaa} so we should enhance this function.
//print $key.'-'.$value.'-'.strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']).'<br>';
if (strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']) === false) {
if (strpos($this->contentXml, $tag) === false && strpos($this->stylesXml , $tag) === false) {
//if (strpos($this->contentXml, '">'. $key . '</text;span>') === false) {
throw new OdfException("var $key not found in the document");
//}
}
$value = $encode ? htmlspecialchars($value) : $value;
$value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value;
$this->vars[$this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']] = str_replace("\n", "<text:line-break/>", $value);
$this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
return $this;
}
/**
* Evaluating php codes inside the ODT and output the buffer (print, echo) inplace of the code
*
*/
public function phpEval()
{
preg_match_all('/[\{\<]\?(php)?\s+(?P<content>.+)\?[\}\>]/iU',$this->contentXml, $matches); // detecting all {?php code ?} or <?php code ? >
for ($i=0;$i < count($matches['content']);$i++) {
try {
$ob_output = ''; // flush the output for each code. This var will be filled in by the eval($code) and output buffering : any print or echo or output will be redirected into this variable
$code = $matches['content'][$i];
ob_start();
eval ($code);
$ob_output = ob_get_contents(); // send the content of the buffer into $ob_output
$this->contentXml = str_replace($matches[0][$i], $ob_output, $this->contentXml);
ob_end_clean();
} catch (Exception $e) {
ob_end_clean();
$this->contentXml = str_replace($matches[0][$i], 'ERROR: there was a problem while evaluating this portion of code, please fix it: '.$e, $this->contentXml);
}
}
return 0;
}
/**
* Assign a template variable as a picture
*
@ -145,7 +174,7 @@ class Odf
$width *= self::PIXEL_TO_CM;
$height *= self::PIXEL_TO_CM;
$xml = <<<IMG
<draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="char" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>
<draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="aschar" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>
IMG;
$this->images[$value] = $file;
$this->setVars($key, $xml, false);
@ -333,8 +362,10 @@ IMG;
throw new OdfException('Error during file export addFromString');
}
foreach ($this->images as $imageKey => $imageValue) {
// Add the image inside the ODT document
$this->file->addFile($imageKey, 'Pictures/' . $imageValue);
$this->addImageToManifest($imageValue);
// Add the image to the Manifest (which maintains a list of images, necessary to avoid "Corrupt ODT file. Repair?" when opening the file with LibreOffice)
$this->addImageToManifest($imageValue);
}
if (! $this->file->addFromString('./META-INF/manifest.xml', $this->manifestXml)) {
throw new OdfException('Error during file export: manifest.xml');
@ -349,15 +380,18 @@ IMG;
*/
public function addImageToManifest($file)
{
$extension = explode('.', $file);
$add = ' <manifest:file-entry manifest:media-type="image/'.$extension[1].'" manifest:full-path="Pictures/'.$file.'"/>'."\n";
$this->manifestXml = str_replace('</manifest:manifest>', $add.'</manifest:manifest>', $this->manifestXml);
// Get the file extension
$ext = substr(strrchr($val, '.'), 1);
// Create the correct image XML entry to add to the manifest (this is necessary because ODT format requires that we keep a list of the images in the manifest.xml)
$add = ' <manifest:file-entry manifest:media-type="image/'.$ext.'" manifest:full-path="Pictures/'.$file.'"/>'."\n";
// Append the image to the manifest
$this->manifestXml = str_replace('</manifest:manifest>', $add.'</manifest:manifest>', $this->manifestXml); // we replace the manifest closing tag by the image XML entry + manifest closing tag (this results in appending the data, we do not overwrite anything)
}
/**
* Export the file as attached file by HTTP
*
* @param string $name (optionnal)
* @param string $name (optional)
* @throws OdfException
* @return void
*/
@ -375,8 +409,42 @@ IMG;
header('Content-type: application/vnd.oasis.opendocument.text');
header('Content-Disposition: attachment; filename="'.$name.'"');
header('Content-Length: '.filesize($this->tmpfile));
readfile($this->tmpfile);
}
/**
* Convert the ODT file to PDF and export the file as attached file by HTTP
* Note: you need to have JODConverter and OpenOffice or LibreOffice installed and executable on the same system as where this php script will be executed. You also need to chmod +x odt2pdf.sh
*
* @param string $name (optional)
* @throws OdfException
* @return void
*/
public function exportAsAttachedPDF($name="")
{
if( $name == "" ) $name = md5(uniqid());
$this->saveToDisk("$name.odt");
exec("./odt2pdf.sh $name",$output,$ret_val);
if($ret_val == 0)
{
if (headers_sent($filename, $linenum)) {
throw new OdfException("headers already sent ($filename at $linenum)");
}
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="'.$name.'.pdf"');
readfile("$name.pdf");
unlink("$name.odt");
unlink("$name.pdf");
} else {
echo "Error occured:<br>";
foreach($output as $line)
echo $line."<br>";
}
}
/**
* Returns a variable of configuration
*

View File

@ -0,0 +1,22 @@
#!/bin/bash
# @copyright GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
if [ -f "$1.odt" ]
then
pgrep -U `id -u` soffice
if [ $? -ne 0 ]
then
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
sleep 2
fi
jodconverter "$1.odt" "$1.pdf"
if [ $? -ne 0 ]
then
echo "Error while converting odt to pdf"
exit 1
fi
sleep 1
else
echo "Error: Odt file does not exist"
exit 1
fi

View File

@ -5,7 +5,7 @@
-- Copyright (C) 2004 Guillaume Delecourt <guillaume.delecourt@opensides.be>
-- Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
--
-- This program is free software; you can redistribute it and/or modify
@ -56,3 +56,4 @@ insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang)
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (26,'MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member',24);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (27,'MEMBER_DELETE','Member deleted','Executed when a member is deleted','member',25);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (28,'BILL_UNVALIDATE','Customer invoice unvalidated','Executed when a customer invoice status set back to draft','facture',10);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (29,'FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',29);

View File

@ -232,3 +232,5 @@ ALTER TABLE llx_societe ADD COLUMN note_public text after note;
ALTER TABLE llx_facture_fourn_det ADD COLUMN info_bits integer NOT NULL DEFAULT 0 after date_end;
ALTER TABLE llx_actioncomm ADD COLUMN transparency integer after fk_user_action;
INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) VALUES (29,'FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',29);

View File

@ -11,6 +11,7 @@ DateToBirth=Data de naiximent
BirthdayAlertOn=alerta aniversari activada
BirthdayAlertOff=alerta aniversari desactivada
Notify_FICHINTER_VALIDATE=Validació fitxa intervenció
Notify_FICHINTER_SENTBYMAIL=Enviament fitxa intervenció per e-mail
Notify_BILL_VALIDATE=Validació factura
Notify_BILL_UNVALIDATE=Devalidació factura a client
Notify_ORDER_SUPPLIER_APPROVE=Aprovació comanda a proveïdor

View File

@ -14,8 +14,8 @@ NewOrder=New order
ToOrder=Make order
MakeOrder=Make order
SupplierOrder=Supplier order
SuppliersOrders=Supplier's orders
SuppliersOrdersRunning=Current supplier's orders
SuppliersOrders=Suppliers orders
SuppliersOrdersRunning=Current suppliers orders
CustomerOrder=Customer order
CustomersOrders=Customer's orders
CustomersOrdersRunning=Current customer's orders

View File

@ -11,6 +11,7 @@ DateToBirth=Date to birth
BirthdayAlertOn= birthday alert active
BirthdayAlertOff= birthday alert inactive
Notify_FICHINTER_VALIDATE=Intervention validated
Notify_FICHINTER_SENTBYMAIL=Intervention sent by mail
Notify_BILL_VALIDATE=Customer invoice validated
Notify_BILL_UNVALIDATE=Customer invoice unvalidated
Notify_ORDER_SUPPLIER_APPROVE=Supplier order approved

View File

@ -11,6 +11,7 @@ DateToBirth=Fecha de nacimiento
BirthdayAlertOn=alerta aniversario activada
BirthdayAlertOff=alerta aniversario desactivada
Notify_FICHINTER_VALIDATE=Validación ficha intervención
Notify_FICHINTER_SENTBYMAIL=Envío ficha de intervención por e-mail
Notify_BILL_VALIDATE=Validación factura
Notify_BILL_UNVALIDATE=Devalidación factura a cliente
Notify_ORDER_SUPPLIER_APPROVE=Aprobación pedido a proveedor

View File

@ -11,6 +11,7 @@ DateToBirth=Date de naissance
BirthdayAlertOn= alerte anniversaire active
BirthdayAlertOff= alerte anniversaire inactive
Notify_FICHINTER_VALIDATE=Validation fiche intervention
Notify_FICHINTER_SENTBYMAIL=Envoye fiche intervention par email
Notify_BILL_VALIDATE=Validation facture client
Notify_BILL_UNVALIDATE=Dévalidation facture client
Notify_ORDER_SUPPLIER_APPROVE=Approbation commande fournisseur

View File

@ -1521,40 +1521,6 @@ class Societe extends CommonObject
}
}
/**
* Return full address of third party
*
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @return string Full address string
*/
function getFullAddress($withcountry=0,$sep="\n")
{
$ret='';
if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php';
$tmparray=getCountry($this->country_id,'all');
$this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
}
else
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
}
return trim($ret);
}
/**
* Return list of contacts emails existing for third party
*

View File

@ -378,7 +378,13 @@ function getSupplierInvoicesForThirdParty($authentication,$idthirdparty)
$obj=$db->fetch_object($resql);
$invoice=new FactureFournisseur($db);
$invoice->fetch($obj->facid);
$result=$invoice->fetch($obj->facid);
if ($result < 0)
{
$error++;
$errorcode=$result; $errorlabel=$invoice->error;
break;
}
// Define lines of invoice
$linesresp=array();

View File

@ -396,7 +396,7 @@ class ContactTest extends PHPUnit_Framework_TestCase
$localobjectadd->town='New town';
$result=$localobjectadd->getFullAddress(1);
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
$this->assertContains("New address\nNew zip New town\nUnited States", $result);
$this->assertContains("New address\nNew town, New zip\nUnited States", $result);
return $localobjectadd->id;
}

View File

@ -413,6 +413,10 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
$object->country_code='US';
$address=dol_format_address($object);
$this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
$object->country_code='AU';
$address=dol_format_address($object);
$this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
}

View File

@ -444,9 +444,10 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$localobjectadd->address='New address';
$localobjectadd->zip='New zip';
$localobjectadd->town='New town';
$localobjectadd->state='New state';
$result=$localobjectadd->getFullAddress(1);
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
$this->assertContains("New address\nNew zip New town\nUnited States", $result);
$this->assertContains("New address\nNew town, New state, New zip\nUnited States", $result);
return $localobjectadd->id;
}

View File

@ -748,7 +748,7 @@
<ns:getSupplierInvoicesForThirdParty soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<authentication xsi:type="ns:authentication">
<!--You may enter the following 5 items in any order-->
<dolibarrkey xsi:type="xsd:string">?</dolibarrkey>
<dolibarrkey xsi:type="xsd:string">dolibarrkey</dolibarrkey>
<sourceapplication xsi:type="xsd:string">?</sourceapplication>
<login xsi:type="xsd:string">admin</login>
<password xsi:type="xsd:string">admin</password>
@ -757,22 +757,7 @@
<idthirdparty xsi:type="xsd:string">all</idthirdparty>
</ns:getSupplierInvoicesForThirdParty>
</soapenv:Body>
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#getSupplierInvoicesForThirdParty"/><con:wsrmConfig version="1.2"/></con:call><con:call name="Request 1"><con:settings/><con:encoding>UTF-8</con:encoding><con:endpoint>http://localhostdolibarr/dolibarrnew/webservices/server_supplier_invoice.php</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.dolibarr.org/ns/">
<soapenv:Header/>
<soapenv:Body>
<ns:getSupplierInvoicesForThirdParty soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<authentication xsi:type="ns:authentication">
<!--You may enter the following 5 items in any order-->
<dolibarrkey xsi:type="xsd:string">?</dolibarrkey>
<sourceapplication xsi:type="xsd:string">?</sourceapplication>
<login xsi:type="xsd:string">?</login>
<password xsi:type="xsd:string">?</password>
<entity xsi:type="xsd:string">?</entity>
</authentication>
<idthirdparty xsi:type="xsd:string">?</idthirdparty>
</ns:getSupplierInvoicesForThirdParty>
</soapenv:Body>
</soapenv:Envelope>]]></con:request><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#getSupplierInvoicesForThirdParty"/></con:call></con:operation></con:interface><con:interface xsi:type="con:WsdlInterface" wsaVersion="NONE" name="WebServicesDolibarrProductOrServiceBinding" type="wsdl" bindingName="{http://www.dolibarr.org/ns/}WebServicesDolibarrProductOrServiceBinding" soapVersion="1_1" anonymous="optional" definition="http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl"><con:part><con:url>http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl</con:url><con:content><![CDATA[<definitions targetNamespace="http://www.dolibarr.org/ns/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.dolibarr.org/ns/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
</soapenv:Envelope>]]></con:request><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.dolibarr.org/ns/#getSupplierInvoicesForThirdParty"/><con:wsrmConfig version="1.2"/></con:call></con:operation></con:interface><con:interface xsi:type="con:WsdlInterface" wsaVersion="NONE" name="WebServicesDolibarrProductOrServiceBinding" type="wsdl" bindingName="{http://www.dolibarr.org/ns/}WebServicesDolibarrProductOrServiceBinding" soapVersion="1_1" anonymous="optional" definition="http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl"><con:part><con:url>http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl</con:url><con:content><![CDATA[<definitions targetNamespace="http://www.dolibarr.org/ns/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.dolibarr.org/ns/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema targetNamespace="http://www.dolibarr.org/ns/">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>