New: Add option to choose pdf paper format
This commit is contained in:
parent
acccbf95cf
commit
bac0610e79
@ -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"),'','').'<br>';
|
||||
$var=true;
|
||||
print '<table summary="more" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
$selected=$conf->global->MAIN_PDF_FORMAT;
|
||||
if (empty($selected)) $selected=dol_getDefaultFormat();
|
||||
|
||||
// Show pdf format
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
|
||||
print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT');
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Addresses
|
||||
print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
|
||||
$var=true;
|
||||
print '<table summary="more" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
// Show prof id 1 in address into pdf
|
||||
$var=!$var;
|
||||
@ -126,9 +148,25 @@ else // Show
|
||||
{
|
||||
$var=true;
|
||||
|
||||
print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
|
||||
// Misc options
|
||||
print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
|
||||
$var=true;
|
||||
print '<table summary="more" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
// Show pdf format
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
|
||||
print $conf->global->MAIN_PDF_FORMAT;
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
// 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 $');
|
||||
?>
|
||||
|
||||
@ -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.= '<select class="flat" name="'.$htmlname.'">';
|
||||
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
if ($showempty)
|
||||
{
|
||||
$out.= '<option value=""';
|
||||
@ -249,7 +249,7 @@ class FormAdmin
|
||||
ksort($menuarray);
|
||||
|
||||
// Affichage liste deroulante des menus
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
$oldprefix='';
|
||||
foreach ($menuarray as $key => $val)
|
||||
{
|
||||
@ -280,7 +280,7 @@ class FormAdmin
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
print '<option value="-1"> </option>';
|
||||
|
||||
$arraytz=array(
|
||||
@ -319,5 +319,59 @@ class FormAdmin
|
||||
print '</select>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
if ($showempty)
|
||||
{
|
||||
$out.= '<option value=""';
|
||||
if ($selected == '') $out.= ' selected="selected"';
|
||||
$out.= '> </option>';
|
||||
}
|
||||
foreach ($paperformat as $key => $value)
|
||||
{
|
||||
if ($selected == $key)
|
||||
{
|
||||
$out.= '<option value="'.$key.'" selected="selected">'.$value.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= '<option value="'.$key.'">'.$value.'</option>';
|
||||
}
|
||||
}
|
||||
$out.= '</select>';
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
14
htdocs/install/mysql/migration/3.1.0-3.2.0.sql
Executable file
14
htdocs/install/mysql/migration/3.1.0-3.2.0.sql
Executable file
@ -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;
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user