Skip to content

Commit

Permalink
Merge branch '3.5' of git@github.com:Dolibarr/dolibarr.git into 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 23, 2014
2 parents 3f78fe8 + e0b4bd9 commit f115501
Show file tree
Hide file tree
Showing 21 changed files with 242 additions and 87 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -41,6 +41,7 @@ Fix: [ bug #1240 ] traduction.
Fix: [ bug #1238 ] When creating accompte with a %, free product are used for calculation.
Fix: [ bug #1280 ] service with not end of date was tagged as expired.
Fix: [ bug #1295 ] Error when creating an agenda extrafield with a number as reference
Fix: [ bug #1306 ] Fatal error when adding an external calendar
New: Added es_CL language

***** ChangeLog for 3.5 compared to 3.4.* *****
Expand Down
3 changes: 2 additions & 1 deletion htdocs/admin/agenda_extsites.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2014 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
Expand Down Expand Up @@ -28,6 +28,7 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

if (!$user->admin)
accessforbidden();
Expand Down
41 changes: 31 additions & 10 deletions htdocs/compta/facture.php
Expand Up @@ -579,14 +579,21 @@
// Convertir en reduc
else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
{
$db->begin();

$object->fetch($id);
$object->fetch_thirdparty();
$object->fetch_lines();

if (!empty($object->paye)) // protection against multiple submit
// Check if there is already a discount (protection to avoid duplicate creation when resubmit post)
$discountcheck=new DiscountAbsolute($db);
$result=$discountcheck->fetch(0,$object->id);

$canconvert=0;
if ($object->type == 3 && $object->paye == 1 && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed completely and not already converted (see real condition into condition used to show button converttoreduc)
if ($object->type == 2 && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and amount of payment is 0 (see real condition into condition used to show button converttoreduc)
if ($canconvert)
{
$db->begin();

// Boucle sur chaque taux de tva
$i=0;
foreach($object->lines as $line)
Expand Down Expand Up @@ -1981,9 +1988,10 @@
}



/*
* View
*/
*/

$form = new Form($db);
$formother=new FormOther($db);
Expand Down Expand Up @@ -2186,6 +2194,7 @@
$options.='</option>';
}

// Show link for credit note
$facids=$facturestatic->list_qualified_avoir_invoices($soc->id);
if ($facids < 0)
{
Expand Down Expand Up @@ -3593,7 +3602,10 @@
}

// Reopen a standard paid invoice
if (($object->type == 0 || $object->type == 1) && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely)
if ((($object->type == 0 || $object->type == 1)
|| ($object->type == 2 && empty($discount->id))
|| ($object->type == 3 && empty($discount->id)))
&& ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely)
{
if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
{
Expand Down Expand Up @@ -3680,23 +3692,32 @@
// For credit note only
if ($object->type == 2 && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement)
{
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create">'.$langs->trans('DoPaymentBack').'</a></div>';
if ($resteapayer == 0)
{
print '<div class="inline-block divButAction"><span class="butActionRefused" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPaymentBack').'</span></div>';
}
else
{
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.'&amp;action=create">'.$langs->trans('DoPaymentBack').'</a></div>';
}
}

// For credit note
if ($object->type == 2 && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->creer && $object->getSommePaiement() == 0)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
}
// For deposit invoice
if ($object->type == 3 && $object->statut == 2 && $resteapayer == 0 && $user->rights->facture->creer && empty($discount->id))
if ($object->type == 3 && $object->paye == 1 && $resteapayer == 0 && $user->rights->facture->creer && empty($discount->id))
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
}
}

// Classify paid (if not deposit and not credit note. Such invoice are "converted")
if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement &&
(($object->type != 2 && $object->type != 3 && $resteapayer <= 0) || ($object->type == 2 && $resteapayer >= 0)) )
// Classify paid
if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != 2 && $object->type != 3 && $resteapayer <= 0) || ($object->type == 2 && $resteapayer >= 0))
|| ($object->type == 3 && $object->paye == 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id))
)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&amp;action=paid">'.$langs->trans('ClassifyPaid').'</a></div>';
}
Expand Down
5 changes: 5 additions & 0 deletions htdocs/core/class/conf.class.php
Expand Up @@ -201,6 +201,11 @@ function setValues($db)
//var_dump($this->modules);
//var_dump($this->modules_parts['theme']);

// If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
// In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
//$this->global->MAIN_SERVER_TZ='Europe/Paris';
if (! empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') date_default_timezone_set($this->global->MAIN_SERVER_TZ);

// Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{
Expand Down
22 changes: 19 additions & 3 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -987,9 +987,9 @@ function dol_getdate($timestamp,$fast=false)
* @param int $month Month (1 to 12)
* @param int $day Day (1 to 31)
* @param int $year Year
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @param int $gm true or 1=Input informations are GMT values, false or 0 or 'server' = local to server TZ, 'user' = local to user TZ
* @param int $check 0=No check on parameters (Can use day 32, etc...)
* @return int Date as a timestamp, '' if error
* @return int Date as a timestamp, '' if error
* @see dol_print_date, dol_stringtotime, dol_getdate
*/
function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
Expand All @@ -1015,7 +1015,23 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)

if (method_exists('DateTime','getTimestamp') && empty($conf->global->MAIN_OLD_DATE))
{
if (empty($gm)) $localtz = new DateTimeZone(date_default_timezone_get());
if (empty($gm) || $gm === 'server')
{
// If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
// In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
if (! empty($conf->global->MAIN_SERVER_TZ))
{
if ($conf->global->MAIN_SERVER_TZ != 'auto') $default_timezone=$conf->global->MAIN_SERVER_TZ;
else $default_timezone=@date_default_timezone_get();
}
else $default_timezone=@date_default_timezone_get();
$localtz = new DateTimeZone($default_timezone);
}
else if ($gm === 'user')
{
$default_timezone=(empty($_SESSION["dol_tz_string"])?'UTC':$_SESSION["dol_tz_string"]);
$localtz = new DateTimeZone($default_timezone);
}
else $localtz = new DateTimeZone('UTC');
$dt = new DateTime(null,$localtz);
$dt->setDate($year,$month,$day);
Expand Down
34 changes: 15 additions & 19 deletions htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
Expand Down Expand Up @@ -109,7 +109,7 @@ function __construct($db)
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - 16; // width of images
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxpicture-=20;
Expand Down Expand Up @@ -153,7 +153,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$outputlangs->load("products");
$outputlangs->load("orders");
$outputlangs->load("deliveries");

if ($conf->commande->dir_output)
{
$object->fetch_thirdparty();
Expand Down Expand Up @@ -228,6 +228,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
$this->posxup+=($this->postotalht - $this->posxdiscount);
$this->posxqty+=($this->postotalht - $this->posxdiscount);
$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
//$this->postotalht;
}

// New page
$pdf->AddPage();
Expand Down Expand Up @@ -304,7 +313,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pagenb+1);
$pdf->setPage($pageposafter+1);
}
}
else
Expand Down Expand Up @@ -400,6 +409,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
//$pdf->SetDrawColor(190,190,200);
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
Expand Down Expand Up @@ -583,20 +593,6 @@ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
$posy=$pdf->GetY()+1;
}
*/
if (! empty($object->date_livraison))
{
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('','B', $default_font_size - 2);
$text=$outputlangs->transnoentities("DeliveryDate").':';
$pdf->MultiCell(80, 3, $text, 0, 'L', 0);

$pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
$text=dol_print_date($object->date_livraison,'day','',$outputlangs);
$pdf->MultiCell(80, 3, $text, 0, 'L', 0);

$posy=$pdf->GetY()+1;
}
/* TODO
else if (! empty($object->availability_code))
{
Expand All @@ -609,7 +605,7 @@ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
$posy=$pdf->GetY()+1;
}*/

// Show shipping date
// Show planed date of delivery
if ($object->date_livraison)
{
$outputlangs->load("sendings");
Expand Down
16 changes: 13 additions & 3 deletions htdocs/core/modules/commande/doc/pdf_proforma.modules.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
Expand Down Expand Up @@ -109,7 +109,7 @@ function __construct($db)
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - 16; // width of images
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxpicture-=20;
Expand Down Expand Up @@ -227,6 +227,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
$this->posxup+=($this->postotalht - $this->posxdiscount);
$this->posxqty+=($this->postotalht - $this->posxdiscount);
$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
//$this->postotalht;
}

// New page
$pdf->AddPage();
Expand Down Expand Up @@ -303,7 +312,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pagenb+1);
$pdf->setPage($pageposafter+1);
}
}
else
Expand Down Expand Up @@ -399,6 +408,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
//$pdf->SetDrawColor(190,190,200);
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/modules/expedition/doc/pdf_merou.modules.php
Expand Up @@ -267,6 +267,7 @@ function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hi
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
//$pdf->SetDrawColor(190,190,200);
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
Expand Up @@ -264,6 +264,7 @@ function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hi
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
//$pdf->SetDrawColor(190,190,200);
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
Expand Down
18 changes: 14 additions & 4 deletions htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
Expand Down Expand Up @@ -109,7 +109,7 @@ function __construct($db)
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - 16; // width of images
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxpicture-=20;
Expand Down Expand Up @@ -228,6 +228,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
$this->posxup+=($this->postotalht - $this->posxdiscount);
$this->posxqty+=($this->postotalht - $this->posxdiscount);
$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
//$this->postotalht;
}

// New page
$pdf->AddPage();
Expand Down Expand Up @@ -306,7 +315,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pagenb+1);
$pdf->setPage($pageposafter+1);
}
}
else
Expand Down Expand Up @@ -378,7 +387,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;

$vatrate=(string) $object->lines[$i]->tva_tx;

// Retrieve type from database for backward compatibility with old records
if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
Expand All @@ -401,6 +410,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
//$pdf->SetDrawColor(190,190,200);
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
Expand Down

0 comments on commit f115501

Please sign in to comment.