Exemplo n.º 1
0
 // If value of entityicon=entitylang='icon:Label'
 $tmparray = explode(':', $entityicon);
 if (count($tmparray) >= 2) {
     $entityicon = $tmparray[0];
     $entitylang = $tmparray[1];
 }
 print img_object('', $entityicon) . ' ' . $langs->trans($entitylang);
 print '</td>';
 $text = $langs->trans($label);
 $tablename = getablenamefromfield($code, $sqlmaxforexport);
 $htmltext = '<b>' . $langs->trans("Name") . ":</b> " . $text . '<br>';
 $htmltext .= '<b>' . $langs->trans("Table") . " -> " . $langs->trans("Field") . ":</b> " . $tablename . " -> " . preg_replace('/^.*\\./', '', $code) . "<br>";
 if (isset($array_selected[$code]) && $array_selected[$code] || $modelchoice == 1) {
     // Selected fields
     print '<td>&nbsp;</td>';
     print '<td align="center"><a href="' . $_SERVER["PHP_SELF"] . '?step=2&datatoexport=' . $datatoexport . '&action=unselectfield&field=' . $code . '">' . img_left() . '</a></td>';
     print '<td>';
     //print $text.'-'.$htmltext."<br>";
     print $form->textwithpicto($text, $htmltext);
     //print ' ('.$code.')';
     print '</td>';
     $bit = 1;
 } else {
     // Fields not selected
     print '<td>';
     //print $text.'-'.$htmltext."<br>";
     print $form->textwithpicto($text, $htmltext);
     //print ' ('.$code.')';
     print '</td>';
     print '<td align="center"><a href="' . $_SERVER["PHP_SELF"] . '?step=2&datatoexport=' . $datatoexport . '&action=selectfield&field=' . $code . '">' . img_right() . '</a></td>';
     print '<td>&nbsp;</td>';
Exemplo n.º 2
0
     $entityicon = $tmparray[0];
     $entitylang = $tmparray[1];
 }
 print img_object('', $entityicon) . ' ' . $langs->trans($entitylang);
 print '</td>';
 $text = $langs->trans($label);
 $tablename = getablenamefromfield($code, $sqlmaxforexport);
 $htmltext = '<b>' . $langs->trans("Name") . ":</b> " . $text . '<br>';
 $htmltext .= '<b>' . $langs->trans("Table") . " -> " . $langs->trans("Field") . ":</b> " . $tablename . " -> " . preg_replace('/^.*\\./', '', $code) . "<br>";
 if (!empty($objexport->array_export_examplevalues[0][$code])) {
     $htmltext .= $langs->trans("SourceExample") . ': <b>' . $objexport->array_export_examplevalues[0][$code] . '</b><br>';
 }
 if (isset($array_selected[$code]) && $array_selected[$code]) {
     // Selected fields
     print '<td>&nbsp;</td>';
     print '<td align="center"><a href="' . $_SERVER["PHP_SELF"] . '?step=2&datatoexport=' . $datatoexport . '&action=unselectfield&field=' . $code . '">' . img_left('default', 0, 'style="max-width: 20px"') . '</a></td>';
     print '<td>';
     //print $text.'-'.$htmltext."<br>";
     print $form->textwithpicto($text, $htmltext);
     //print ' ('.$code.')';
     print '</td>';
 } else {
     // Fields not selected
     print '<td>';
     //print $text.'-'.$htmltext."<br>";
     print $form->textwithpicto($text, $htmltext);
     //print ' ('.$code.')';
     print '</td>';
     print '<td align="center"><a href="' . $_SERVER["PHP_SELF"] . '?step=2&datatoexport=' . $datatoexport . '&action=selectfield&field=' . $code . '">' . img_right('default', 0, 'style="max-width: 20px"') . '</a></td>';
     print '<td>&nbsp;</td>';
 }
    function formObjectOptions($parameters, &$object, &$action, $hookmanager)
    {
        $error = 0;
        // Error counter
        $myvalue = '';
        // A result value
        if (in_array('propalcard', explode(':', $parameters['context'])) || in_array('ordercard', explode(':', $parameters['context']))) {
            global $langs, $conf;
            $langs->load('free2product@free2product');
            $base_new_ref = !empty($conf->global->FREE2PRODUCT_BASE_NEWREF) ? $conf->global->FREE2PRODUCT_BASE_NEWREF : 'FREELINE-';
            if (!empty($object->lines)) {
                ?>
<script type="text/javascript">
					function convertAllFreeLine() {
						$('#convertAllFreeLine_popup').dialog({
							title:"<?php 
                echo $langs->transnoentities('convertAllFreeLine');
                ?>
"
							,modal:true
							,width:'80%'
							,buttons: {
					        	"Convertir ces lignes": function() {
					        		$('#convertAllFreeLine_popup input[lineid]').each(function(i,item) {
					        			
					        			$item = $(item); 
					        			
					        			var ref = $item.val();
										var lineid = $item.attr('lineid');
										var label = $item.attr('label');
										var qty = $item.attr('qty');
										var price = $item.attr('price');
										var product_type = $item.attr('product_type');
										var tva = $item.attr('tva');
										
					        			convert_free2product(lineid,ref,label,qty,price,product_type,tva);
					        		});
					        		
					        		
					        		
					        		document.location.href="<?php 
                if ($object->element == 'propal') {
                    echo dol_buildpath('/comm/propal.php?id=' . $object->id, 1);
                } else {
                    if ($object->element == 'commande') {
                        echo dol_buildpath('/commande/card.php?id=' . $object->id, 1);
                    }
                }
                ?>
";
					          		$( this ).dialog( "close" );
					        	}
							}
						});
					}
					
					function redirect()
					{
						document.location.href="<?php 
                if ($object->element == 'propal') {
                    echo dol_buildpath('/comm/propal.php?id=' . $object->id, 1);
                } else {
                    if ($object->element == 'commande') {
                        echo dol_buildpath('/commande/card.php?id=' . $object->id, 1);
                    }
                }
                ?>
";
					}
						
					function convert_free2product(lineid,ref,label,qty,price,product_type,tva) {
						
						if(ref) {
							$.ajax({
								url:"<?php 
                echo dol_buildpath('/free2product/script/interface.php', 1);
                ?>
"
								,data:{
									put:'change-line'
									,lineid:lineid
									,qty:qty
									,label:label
									,price:price
									,ref:ref	
									,product_type:product_type
									,tva:tva
									,element:"<?php 
                echo $object->element;
                ?>
"
								}
								,async:false
							}).done(function(fk_product) {
								if(fk_product<=0)alert('ErrorDuringConversion '+ref);
								
							});
							
							redirect();
						}
						
					}
						
					function free2product(lineid) {
						
						$a = $('a[lineid='+lineid+']'); 
						var label = $a.attr('label');
						var qty = $a.attr('qty');
						var price = $a.attr('price');
						var product_type = $a.attr('product_type');
						var tva = $a.attr('tva');
						
						var ref = window.prompt("<?php 
                echo $langs->transnoentities('ConvertToNewProductRef');
                ?>
","<?php 
                echo $base_new_ref;
                ?>
"+lineid);
						convert_free2product(lineid,ref,label,qty,price,product_type,tva);
						
						
						
								
					}
				
					$(document).ready(function () {<?php 
                global $addButtonToConvertAll;
                $addButtonToConvertAll = false;
                foreach ($object->lines as &$line) {
                    if ($line->product_type <= 1 && $line->fk_product == 0) {
                        // Ceci est une ligne libre
                        $addButtonToConvertAll = true;
                        $lineid = !empty($line->id) ? $line->id : $line->rowid;
                        // compatibilité 3.6
                        $desc = !empty($line->desc) ? $line->desc : $line->description;
                        $link = '<a href="javascript:;" style="float:left;"';
                        $link .= ' onclick="free2product(' . $lineid . ')" lineid="' . $lineid . '"';
                        $link .= ' label="' . htmlentities(addslashes(strtr($desc, array("\n" => '\\n', "\r" => '')))) . '"';
                        $link .= ' qty="' . $line->qty . '" price="' . $line->subprice . '"';
                        $link .= ' product_type="' . $line->product_type . '" tva="' . $line->tva_tx . '" >';
                        $link .= img_left($langs->trans('MakeAsProduct')) . '</a>';
                        ?>
						$('tr#row-<?php 
                        echo $lineid;
                        ?>
 td:first').prepend('<?php 
                        echo $link;
                        ?>
');
						<?php 
                    }
                }
                ?>
				});
				</script>
				<?php 
            }
        }
        if (!$error) {
            return 0;
            // or return 1 to replace standard code
        } else {
            $this->errors[] = $error_msg;
            return -1;
        }
    }