From 9c8a9ff7dc97cd9b6bc2bf2f20ec89b4f0377ba4 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 11 Mar 2013 23:35:31 +0100 Subject: [PATCH 01/54] Print IPP --- htdocs/compta/facture.php | 12 +++++++++- htdocs/core/class/dolprintipp.class.php | 31 +++++++++++++++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 17947e6e3ed..3a28ddb22a5 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1673,6 +1673,14 @@ else if ($action == 'remove_file') } } +// Print file +else if ($action == 'print_file' AND $user->rights->printipp->use) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php'; + $printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD); + $printer->print_file(GETPOST('file',alpha),GETPOST('printer',alpha)); +} + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { if ($action == 'addcontact') @@ -3421,9 +3429,11 @@ else if ($id > 0 || ! empty($ref)) $urlsource=$_SERVER['PHP_SELF'].'?facid='.$object->id; $genallowed=$user->rights->facture->creer; $delallowed=$user->rights->facture->supprimer; + $printer = false; + if ($user->rights->printipp->use AND $conf->printipp->enabled) $printer = true; print '
'; - print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); + print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$printer); $somethingshown=$formfile->numoffiles; /* diff --git a/htdocs/core/class/dolprintipp.class.php b/htdocs/core/class/dolprintipp.class.php index 30ddbfe254a..e4507de19b8 100644 --- a/htdocs/core/class/dolprintipp.class.php +++ b/htdocs/core/class/dolprintipp.class.php @@ -138,10 +138,33 @@ class dolprintIPP $ipp->setPrinterURI("ipp://localhost:631/printers/"); } } - echo 'Jobs for : '.$this->userid.' module : '.$module.' Printer : '.$obj->printer_name.'
'; - echo "Getting Jobs: ".$ipp->getJobs(true,3,"completed",true)."
"; - - echo "
";print_r($ipp->jobs_attributes); echo "
"; + // Getting Jobs + $ipp->getJobs(false,0,'completed',false); + print ''; + print ''; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $jobs = $ipp->jobs_attributes; + $var = True; + //print '
'.print_r($jobs,true).'
'; + foreach ($jobs as $value ) + { + $var=!$var; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + print "
IdOwnerPrinterFileStatusCancel
'.$value->job_id->_value0.''.$value->job_originating_user_name->_value0.''.$value->printer_uri->_value0.''.$value->job_name->_value0.''.$value->job_state->_value0.''.$value->job_uri->_value0.'
"; } } ?> From 33e6654454f20d118e96918873a8a49e8be4a684 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Tue, 12 Mar 2013 01:06:49 +0100 Subject: [PATCH 02/54] print ipp --- htdocs/core/class/dolprintipp.class.php | 20 +++++++++++++++ htdocs/printipp/admin/printipp.php | 33 +++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/dolprintipp.class.php b/htdocs/core/class/dolprintipp.class.php index e4507de19b8..78a2af281f2 100644 --- a/htdocs/core/class/dolprintipp.class.php +++ b/htdocs/core/class/dolprintipp.class.php @@ -104,6 +104,7 @@ class dolprintIPP $ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT); } } + // Set number of copy $ipp->setCopies($obj->copy); $ipp->setData(DOL_DATA_ROOT.'/'.$module.'/'.$file); $ipp->printJob(); @@ -166,5 +167,24 @@ class dolprintIPP } print ""; } + + /** + * Get printer detail + * + */ + function get_printer_detail($uri) + { + global $conf,$db; + + include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; + $ipp = new CupsPrintIPP(); + $ipp->setLog(DOL_DATA_ROOT.'/printipp.log','file',3); // logging very verbose + $ipp->setHost($this->host); + $ipp->setPort($this->port); + $ipp->setUserName($this->userid); + $ipp->setPrinterURI($uri); + $ipp->getPrinterAttributes(); + return $ipp->printer_attributes; + } } ?> diff --git a/htdocs/printipp/admin/printipp.php b/htdocs/printipp/admin/printipp.php index 34163f125ec..d82196fd3b4 100644 --- a/htdocs/printipp/admin/printipp.php +++ b/htdocs/printipp/admin/printipp.php @@ -145,10 +145,39 @@ if ($mode=='test'&& $user->admin) print ''; $printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD); $var=true; + print '
'; print ''; - print ''; - print print_r($printer->getlist_available_printers(),true); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; print "\n"; + $list = $printer->getlist_available_printers(); + $var = True; + foreach ($list as $value ) + { + $var=!$var; + $printer_det = $printer->get_printer_detail($value); + print ""; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + print "\n"; + } print '
'.$langs->trans("TestConnect").'UriNameStateState_reasonState_reason1BWColorDeviceMediaSupported
'.$value.'
'.print_r($printer_det,true).'
'.$printer_det->printer_name->_value0.''.$printer_det->printer_state->_value0.''.$printer_det->printer_state_reasons->_value0.''.$printer_det->printer_state_reasons->_value1.''.$printer_det->printer_type->_value2.''.$printer_det->printer_type->_value3.''.$printer_det->device_uri->_value0.''.$printer_det->media_default->_value0.''.$printer_det->media_type_supported->_value1.'
'; } From 4c29eaecd1b9bebe07f145d268a9cc37ef6c66e0 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Tue, 26 Mar 2013 10:23:00 +0100 Subject: [PATCH 03/54] Print IPP --- htdocs/commande/fiche.php | 6 +++-- htdocs/compta/facture.php | 4 ++-- htdocs/core/modules/modPrintIPP.class.php | 4 ++-- htdocs/printipp/admin/printipp.php | 27 +++++++++++++++++++++++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 52b7761adbe..38ea4c57355 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1103,11 +1103,13 @@ else if ($action == 'remove_file') } // Print file -else if ($action == 'print_file' AND $user->rights->printipp->use) +else if ($action == 'print_file' AND $user->rights->printipp->read) { require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php'; $printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD); $printer->print_file(GETPOST('file',alpha),GETPOST('printer',alpha)); + setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); + $action=''; } /* @@ -2363,7 +2365,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $genallowed=$user->rights->commande->creer; $delallowed=$user->rights->commande->supprimer; $printer = false; - if ($user->rights->printipp->use AND $conf->printipp->enabled) $printer = true; + if ($user->rights->printipp->read AND $conf->printipp->enabled) $printer = true; $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$printer); /* diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 3a28ddb22a5..108d3441c16 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1674,7 +1674,7 @@ else if ($action == 'remove_file') } // Print file -else if ($action == 'print_file' AND $user->rights->printipp->use) +else if ($action == 'print_file' AND $user->rights->printipp->read) { require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php'; $printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD); @@ -3430,7 +3430,7 @@ else if ($id > 0 || ! empty($ref)) $genallowed=$user->rights->facture->creer; $delallowed=$user->rights->facture->supprimer; $printer = false; - if ($user->rights->printipp->use AND $conf->printipp->enabled) $printer = true; + if ($user->rights->printipp->read AND $conf->printipp->enabled) $printer = true; print '
'; print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$printer); diff --git a/htdocs/core/modules/modPrintIPP.class.php b/htdocs/core/modules/modPrintIPP.class.php index 53cadf53699..47ae72e3493 100644 --- a/htdocs/core/modules/modPrintIPP.class.php +++ b/htdocs/core/modules/modPrintIPP.class.php @@ -95,7 +95,7 @@ class modPrintIPP extends DolibarrModules $this->rights[$r][1] = 'Printer'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 1; - $this->rights[$r][4] = 'use'; + $this->rights[$r][4] = 'read'; // Main menu entries $this->menus = array(); // List of menus to add @@ -110,7 +110,7 @@ class modPrintIPP extends DolibarrModules 'langs'=>'printipp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>100, 'enabled'=>'$conf->printipp->enabled', - 'perms'=>'$user->rights->printipp->use', // Use 'perms'=>'1' if you want your menu with no permission rules + 'perms'=>'$user->rights->printipp->read', // Use 'perms'=>'1' if you want your menu with no permission rules 'target'=>'', 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both diff --git a/htdocs/printipp/admin/printipp.php b/htdocs/printipp/admin/printipp.php index d82196fd3b4..6ea4e1dd2f9 100644 --- a/htdocs/printipp/admin/printipp.php +++ b/htdocs/printipp/admin/printipp.php @@ -44,6 +44,12 @@ if (!$mode) $mode='config'; if ($action == 'setvalue' && $user->admin) { $db->begin(); + if (GETPOST('PRINTIPP_ENABLED','alpha') == '1') $result=dolibarr_set_const($db, "PRINTIPP_ENABLED",1,'yesno',0,'',$conf->entity); + else + { + $result=dolibarr_del_const($db, "PRINTIPP_ENABLED",$conf->entity); + } + if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PRINTIPP_HOST",GETPOST('PRINTIPP_HOST','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PRINTIPP_PORT",GETPOST('PRINTIPP_PORT','alpha'),'chaine',0,'',$conf->entity); @@ -101,6 +107,27 @@ if ($mode=='config'&& $user->admin) print ''.$langs->trans("Value").''; print "\n"; + $var=!$var; + print ''; + print $langs->trans("PRINTIPP_ENABLED").''; + + if (! empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff('PRINTIPP_ENABLED'); + } + else + { + if (empty($conf->global->PRINTIPP_ENABLED)) + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + else + { + print ''.img_picto($langs->trans("Enabled"),'on').''; + } + } + print ''; + $var=!$var; print ''; print $langs->trans("PRINTIPP_HOST").''; From 880a27f827483b80af304d6470d5f2050d5df529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Tue, 4 Jun 2013 18:40:46 +0200 Subject: [PATCH 04/54] Fixed field name --- htdocs/societe/societe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php index 4e4374fc69a..89187914c04 100644 --- a/htdocs/societe/societe.php +++ b/htdocs/societe/societe.php @@ -98,7 +98,7 @@ if ($mode == 'search') if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ if (! $user->rights->societe->lire || ! $user->rights->fournisseur->lire) { - if (! $user->rights->fournisseur->lire) $sql.=" AND s.fourn != 1"; + if (! $user->rights->fournisseur->lire) $sql.=" AND s.fournisseur != 1"; } // Insert sale filter if ($search_sale) From a4841dacda59fec0e7a04d719dfc72648c84276f Mon Sep 17 00:00:00 2001 From: simnandez Date: Wed, 5 Jun 2013 15:09:13 +0200 Subject: [PATCH 05/54] Fix: Warning missing argument 2 into withdrawals --- htdocs/compta/prelevement/rejets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index 6cd04c95162..bebc56abbeb 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2005-2012 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -57,7 +57,7 @@ if ($sortorder == "") $sortorder="DESC"; if ($sortfield == "") $sortfield="p.datec"; $rej = new RejetPrelevement($db, $user); -$ligne = new LignePrelevement($db); +$ligne = new LignePrelevement($db, $user); /* * Liste des factures From 693f4f3b8bfa99fef1f89c01fe06e51e17bd5d3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 Jun 2013 21:25:10 +0200 Subject: [PATCH 06/54] Fix: Pb of offset in numbering. Add also phpunit test to detect and test fix. Conflicts: test/phpunit/NumberingModulesTest.php --- htdocs/core/lib/functions2.lib.php | 11 +++++++---- test/phpunit/NumberingModulesTest.php | 12 ++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index ab41e5aaec7..66b64035c4d 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -607,7 +607,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskraz=$yearoffsettype; // For backward compatibility else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; - //print "maskraz=".$maskraz; + //print "maskraz=".$maskraz; // -1=no reset if ($maskraz > 0) // A reset is required { @@ -699,8 +699,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $sqlwhere.='(SUBSTRING('.$field.', '.(dol_strlen($reg[1])+1).', '.dol_strlen($reg[2]).") = '".$yearcomp."')"; } } - //print "sqlwhere=".$sqlwhere."
\n"; - //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset." yearcomp=".$yearcomp."
\n"; + //print "sqlwhere=".$sqlwhere." yearcomp=".$yearcomp."
\n"; // sqlwhere and yearcomp defined only if we ask a reset + //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."
\n"; // Define $sqlstring $posnumstart=strpos($maskwithnocode,$maskcounter); // Pos of counter in final string (from 0 to ...) @@ -739,7 +739,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $counter = $obj->val; } else dol_print_error($db); + + // Check if we must force counter to maskoffset if (empty($counter) || preg_match('/[^0-9]/i',$counter)) $counter=$maskoffset; + else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset; if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. { @@ -824,7 +827,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m } else dol_print_error($db); if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset; - $maskrefclient_counter++; + $maskrefclient_counter++; } // Build numFinal diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 82bb96dc0be..5e93e32fe22 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -147,7 +147,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result=$localobject->is_erasable(); print __METHOD__." is_erasable=".$result."\n"; $this->assertEquals(1, $result); // Can be deleted - + $localobject2=new Facture($this->savdb); $localobject2->initAsSpecimen(); $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask) @@ -166,7 +166,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result=$localobject->is_erasable(); print __METHOD__." is_erasable=".$result."\n"; $this->assertEquals(0, $result); // Case 1 can not be deleted (case 2 is more recent) - + // Now we try with a reset $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}'; $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}'; @@ -194,7 +194,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result=$localobject->is_erasable(); print __METHOD__." is_erasable=".$result."\n"; $this->assertEquals(1, $result); // Can be deleted - + $localobject2=new Facture($this->savdb); $localobject2->initAsSpecimen(); $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required) @@ -210,7 +210,11 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result=$localobject->is_erasable(); print __METHOD__." is_erasable=".$result."\n"; $this->assertEquals(1, $result); // Case 1 can be deleted (because there was a reset for case 2) - + + // Try an offset when an invoice already exists + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}'; + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}'; + $result=$numbering->getNextValue($mysoc, $localobject2); // Now we try with a different fiscal month (forced by mask) $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}'; From c78d5aa4a78a829849b7ec9dec1f3cf34c913d38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Jun 2013 14:52:25 +0200 Subject: [PATCH 07/54] Fix: Bad param 'zone' into printCommon --- htdocs/main.inc.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f22110f57d7..86419f2bdaf 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1149,7 +1149,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || (! empty($conf->dol_use_jmobile) && $conf->dol_use_jmobile > 0)) { // We must force not using ajax because cache of jquery does not load js of other pages. - // This also increase seriously speed onto mobile device where complex js code is very slow and memory very low. + // This also increase seriously speed onto mobile device where complex js code is very slow and memory very low. if (empty($conf->dol_use_jmobile) || $conf->dol_use_jmobile != 2) { print '