diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index 0760b708a8c..c1736b854ca 100755
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -20,7 +20,7 @@
/**
* \file htdocs/admin/pdf.php
* \brief Page to setup PDF options
- * \version $Id: pdf.php,v 1.1 2011/08/10 23:48:09 eldy Exp $
+ * \version $Id: pdf.php,v 1.2 2011/08/11 01:34:54 eldy Exp $
*/
require("../main.inc.php");
@@ -44,8 +44,10 @@ if (!$user->admin)
if (isset($_POST["action"]) && $_POST["action"] == 'update')
{
+ dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
+
dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity);
@@ -82,11 +84,31 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') // Edit
clearstatcache();
- // PDF
+ // Misc options
+ print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').' ';
+ $var=true;
+ print '
';
+ print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
+
+ $selected=$conf->global->MAIN_PDF_FORMAT;
+ if (empty($selected)) $selected=dol_getDefaultFormat();
+
+ // Show pdf format
+ $var=!$var;
+ print ''.$langs->trans("DictionnaryPaperFormat").' ';
+ print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT');
+ print ' ';
+
+ print '
';
+
+ print ' ';
+
+
+ // Addresses
print_fiche_titre($langs->trans("PDFAddressForging"),'','').' ';
$var=true;
print '';
- print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
+ print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
// Show prof id 1 in address into pdf
$var=!$var;
@@ -126,9 +148,25 @@ else // Show
{
$var=true;
- print_fiche_titre($langs->trans("PDFAddressForging"),'','').' ';
+ // Misc options
+ print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').' ';
+ $var=true;
+ print '';
+ print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
+
+ // Show pdf format
+ $var=!$var;
+ print ''.$langs->trans("DictionnaryPaperFormat").' ';
+ print $conf->global->MAIN_PDF_FORMAT;
+ print ' ';
+
+ print '
';
+
+ print ' ';
+
+ print_fiche_titre($langs->trans("PDFAddressForging"),'','').' ';
print '';
- print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
+ print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
// Show prof id 1 in address into pdf
$var=!$var;
@@ -166,5 +204,5 @@ else // Show
$db->close();
-llxFooter('$Date: 2011/08/10 23:48:09 $ - $Revision: 1.1 $');
+llxFooter('$Date: 2011/08/11 01:34:54 $ - $Revision: 1.2 $');
?>
diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php
index 23baf771908..96082b386a3 100644
--- a/htdocs/core/class/html.formadmin.class.php
+++ b/htdocs/core/class/html.formadmin.class.php
@@ -21,7 +21,7 @@
* \file htdocs/core/class/html.formadmin.class.php
* \ingroup core
* \brief File of class for html functions for admin pages
- * \version $Id: html.formadmin.class.php,v 1.23 2011/07/31 23:45:14 eldy Exp $
+ * \version $Id: html.formadmin.class.php,v 1.24 2011/08/11 01:34:54 eldy Exp $
*/
@@ -77,7 +77,7 @@ class FormAdmin
$out='';
- $out.= '';
+ $out.= '';
if ($showempty)
{
$out.= '';
+ print '';
$oldprefix='';
foreach ($menuarray as $key => $val)
{
@@ -280,7 +280,7 @@ class FormAdmin
{
global $langs,$conf;
- print '';
+ print '';
print ' ';
$arraytz=array(
@@ -319,5 +319,59 @@ class FormAdmin
print ' ';
}
+
+
+ /**
+ * Return html select list with available languages (key='en_US', value='United States' for example)
+ * @param selected Langue pre-selectionnee
+ * @param htmlname Nom de la zone select
+ * @param filter Key to filter
+ * @param showempty Add empty value
+ */
+ function select_paper_format($selected='',$htmlname='paperformat_id',$filter=0,$showempty=0)
+ {
+ global $langs;
+
+ $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format where active=1";
+ if ($filter) $sql.=" WHERE code LIKE '%".$filter."%'";
+
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $num=$this->db->num_rows($resql);
+ $i=0;
+ while ($i < $num)
+ {
+ $obj=$this->db->fetch_object($resql);
+ $paperformat[$obj->code]=$obj->label.' - '.round($obj->width).'x'.round($obj->height).' '.$obj->unit;
+
+ $i++;
+ }
+ }
+ else dol_print_error($this->db);
+ $out='';
+
+ $out.= '';
+ if ($showempty)
+ {
+ $out.= ' ';
+ }
+ foreach ($paperformat as $key => $value)
+ {
+ if ($selected == $key)
+ {
+ $out.= ''.$value.' ';
+ }
+ else
+ {
+ $out.= ''.$value.' ';
+ }
+ }
+ $out.= ' ';
+
+ return $out;
+ }
}
?>
diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql
new file mode 100755
index 00000000000..def16980331
--- /dev/null
+++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql
@@ -0,0 +1,14 @@
+--
+-- $Id: 3.1.0-3.2.0.sql,v 1.1 2011/08/11 01:34:54 eldy Exp $
+--
+-- Be carefull to requests order.
+-- This file must be loaded by calling /install/index.php page
+-- when current version is 2.8.0 or higher.
+--
+-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
+-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
+-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
+-- To change type of field: ALTER TABLE llx_table MODIFY name varchar(60);
+--
+
+UPDATE llx_c_paper_format SET active=1 WHERE active=0;
\ No newline at end of file
diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php
index ef9875dc6d3..d1f473a7d4d 100644
--- a/htdocs/lib/functions2.lib.php
+++ b/htdocs/lib/functions2.lib.php
@@ -21,10 +21,23 @@
* \file htdocs/lib/functions2.lib.php
* \brief A set of functions for Dolibarr
* This file contains all rare functions.
- * \version $Id: functions2.lib.php,v 1.76 2011/07/31 23:26:00 eldy Exp $
+ * \version $Id: functions2.lib.php,v 1.77 2011/08/11 01:34:55 eldy Exp $
*/
+/**
+ * Return default paper format code
+ * @return string Defautl paper format code
+ */
+function dol_getDefaultFormat()
+{
+ global $langs;
+ $selected='EUA4';
+ if ($langs->defaultlang == 'ca_CA') $selected='CAP4'; // Canada
+ if ($langs->defaultlang == 'en_US') $selected='USLetter'; // US
+ return $selected;
+}
+
/**
* Output content of a file $filename in version of current language (otherwise may use an alternate language)