diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 28feb8ab23e8db8fd585eb5a59d3a40e408a6f2b..717a25aa8b36394f1d9c95491c9046b1abc2270f 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -76,6 +76,7 @@ $workflowcodes=array( 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'), + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'), // For the following 2 options, if module invoice is disabled, they does not exists, so "Classify billed" for order must be done manually from order card. 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>40, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'), 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify', 'position'=>50, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'), @@ -110,8 +111,8 @@ foreach($workflowcodes as $key => $params) print ' <td align="center">'.$langs->trans("Status").'</td>'; print "</tr>\n"; $oldfamily = $family; - } - + } + $var = !$var; print "<tr ".$bc[$var].">\n"; print "<td>".img_object('', $picto).$langs->trans('desc'.$key); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 0e57118f4bb6094243157241fb11b2f67a5b45d8..bd7ee30c2779cb48a4f3d4fb07da007f5e6d74f4 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -619,6 +619,9 @@ class FormFile $out.= ' target="_blank">'; $out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]).' '.dol_trunc($file["name"],$maxfilenamelength); $out.= '</a>'."\n"; + + $out.= $this->showPreview($file,$modulepart,$relativepath); + $out.= '</td>'; // Show file size @@ -739,6 +742,8 @@ class FormFile $out.= img_mime($relativepath, $file["name"]); $out.= '</a>'."\n"; + $out.= $this->showPreview($file,$modulepart,$relativepath); + $this->infofiles['nboffiles']++; $this->infofiles['files'][]=$file['fullname']; $ext=pathinfo($file["name"], PATHINFO_EXTENSION); @@ -859,6 +864,9 @@ class FormFile //print dol_trunc($file['name'],$maxlength,'middle'); print $file['name']; print '</a>'; + + print $this->showPreview($file,$modulepart,$filepath); + print "</td>\n"; print '<td align="right" width="80px">'.dol_print_size($file['size'],1,1).'</td>'; print '<td align="center" width="130px">'.dol_print_date($file['date'],"dayhour","tzuser").'</td>'; @@ -1320,5 +1328,30 @@ class FormFile return $nboflinks; } + /** + * Show detail icon with link for preview + * @param array $file File + * @param string $modulepart propal, facture, facture_fourn, ... + * @param string $relativepath Relative path of docs + * @return string $out Output string with HTML + */ + public function showPreview($file, $modulepart, $relativepath){ + global $langs, $conf; + + if (empty($conf->use_javascript_ajax)) return ''; + + $out=''; + + $mime_preview = array('jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css'); + $num_mime = array_search(dol_mimetype($file['name'], '', 1), $mime_preview); + + if( $num_mime!== false){ + $out.= ' <a href="javascript:document_preview(\''.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).'\',\''.dol_mimetype($file['name']).'\', \''.$file['name'].'\')">'; + $out.= img_picto($langs->trans('Preview'), 'detail').'</a>'; + + return $out; + } + } + } diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 0baea91412f6ebd22468f74a6c0b6d8009e39abf..d64b05ccd8c95e9f32dfa400c3822788c9812be7 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -948,6 +948,65 @@ function copyToClipboard(text,text2) return false; } +/* + * Function show document preview + * @params string file File path + * @params string type mime file + * @params string title + */ +function document_preview(file, type, title){ + + var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"]; + + if ($.inArray(type, ValidImageTypes) < 0) { + var width='85%'; + var object_width='100%'; + var height = $( window ).height()*0.90; + var object_height='98%'; + + show_preview(); + + } else { + var object_width=0; + var object_height=0; + + var img = new Image(); + + img.onload = function() { + object_width = this.width; + object_height = this.height; + + width = $( window ).width()*0.90; + if(object_width < width){ + width = object_width + 30 + } + height = $( window ).height()*0.85; + if(object_height < height){ + height = object_height + 80 + } + + show_preview(); + + }; + img.src = file; + + } + function show_preview(){ + + var newElem = '<object data="'+file+'" type="'+type+'" width="'+object_width+'" height="'+object_height+'"></object>'; + + $("#dialogforpopup").html(newElem); + $("#dialogforpopup").dialog({ + closeOnEscape: true, + resizable: true, + width: width, + height: height, + modal: true, + title: title + }); + } +} + /* * Provide a function to get an URL GET parameter in javascript * diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index b0b4893d485acb8bd05ddd9b9e8408421b395bcd..fd97edc808931d74935fb8d18f8607e119d5adf1 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -64,7 +64,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers $newobject->context['createfrompropal'] = 'createfrompropal'; $newobject->context['origin'] = $object->element; $newobject->context['origin_id'] = $object->id; - + $ret=$newobject->createFromProposal($object); if ($ret < 0) { $this->error=$newobject->error; $this->errors[]=$newobject->error; } return $ret; @@ -83,7 +83,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers $newobject->context['createfromorder'] = 'createfromorder'; $newobject->context['origin'] = $object->element; $newobject->context['origin_id'] = $object->id; - + $ret=$newobject->createFromOrder($object); if ($ret < 0) { $this->error=$newobject->error; $this->errors[]=$newobject->error; } return $ret; @@ -144,6 +144,19 @@ class InterfaceWorkflowManager extends DolibarrTriggers } return $ret; } + + if (! empty($conf->propal->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) + { + $object->fetchObjectLinked('','propal',$object->id,$object->element); + if (! empty($object->linkedObjects)) + { + foreach($object->linkedObjects['propal'] as $element) + { + $ret=$element->classifyBilled($user); + } + } + return $ret; + } } return 0; diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 1c59a3651ec9fd5352e47e3558c43a670bf45178..688938f28eadd4846f270d7af3259f7036c57079 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -9,3 +9,4 @@ descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice af descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer order is set to paid descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is validated +descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer invoice is validated