Example #1
0
     // Surface
     print '<tr><td>' . $langs->trans("Surface") . '</td><td colspan="3">';
     print '<input name="surface" size="4" value="' . GETPOST('surface') . '">';
     print $formproduct->select_measuring_units("surface_units", "surface");
     print '</td></tr>';
     // Volume
     print '<tr><td>' . $langs->trans("Volume") . '</td><td colspan="3">';
     print '<input name="volume" size="4" value="' . GETPOST('volume') . '">';
     print $formproduct->select_measuring_units("volume_units", "volume");
     print '</td></tr>';
 }
 // Units
 if ($conf->global->PRODUCT_USE_UNITS) {
     print '<tr><td>' . $langs->trans('DefaultUnitToShow') . '</td>';
     print '<td colspan="3">';
     print $form->selectUnits('', 'units');
     print '</td></tr>';
 }
 // Custom code
 if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
     print '<tr><td>' . $langs->trans("CustomCode") . '</td><td><input name="customcode" size="10" value="' . GETPOST('customcode') . '"></td>';
     // Origin country
     print '<td>' . $langs->trans("CountryOrigin") . '</td><td>';
     print $form->select_country(GETPOST('country_id', 'int'), 'country_id');
     if ($user->admin) {
         print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
     }
     print '</td></tr>';
 }
 // Other attributes
 $parameters = array('colspan' => 3);
Example #2
0
 $nbrows = ROWS_2;
 if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
     $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
 }
 $enable = isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0;
 $doleditor = new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, 70);
 $doleditor->Create();
 print '</td>';
 print '<td align="right">';
 print $form->load_tva("eltva_tx", $objp->tva_tx, $mysoc, $object->thirdparty);
 print '</td>';
 print '<td align="right"><input size="5" type="text" name="elprice" value="' . price($objp->subprice) . '"></td>';
 print '<td align="center"><input size="2" type="text" name="elqty" value="' . $objp->qty . '"></td>';
 if ($conf->global->PRODUCT_USE_UNITS) {
     print '<td align="left">';
     print $form->selectUnits($objp->fk_unit, "unit");
     print '</td>';
 }
 print '<td align="right" class="nowrap"><input size="1" type="text" name="elremise_percent" value="' . $objp->remise_percent . '">%</td>';
 if (!empty($usemargins)) {
     print '<td align="right">';
     if ($objp->fk_product) {
         print '<select id="fournprice" name="fournprice"></select>';
     }
     print '<input id="buying_price" type="text" size="5" name="buying_price" value="' . price($objp->pa_ht, 0, '', 0) . '"></td>';
 }
 print '<td align="center" rowspan="2" valign="middle"><input type="submit" class="button" name="save" value="' . $langs->trans("Modify") . '">';
 print '<br><input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
 print '</td>';
 $colspan = 5;
 if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) {
function fiche_preview(&$object, &$TData)
{
    global $langs, $user, $db, $conf;
    //var_dump($_REQUEST);exit;
    $origin = GETPOST('origin');
    $head = null;
    if ($object->element == 'propal') {
        $head = propal_prepare_head($object);
    } else {
        $head = commande_prepare_head($object);
    }
    if (empty($user->rights->importdevis->myactions)) {
        accessforbidden();
        exit;
    }
    $form = new Form($db);
    llxHeader();
    $title = $langs->trans('Import');
    if ($origin == 'propal') {
        dol_fiche_head($head, 'importdevis', $title, 0, 'propal');
    } else {
        dol_fiche_head($head, 'importdevis', $title, 0, 'commande');
    }
    ?>
		<style type="text/css">
			#table_before_import tr.title_line td.for_line > * {
				display:none;
			}
			
			#table_before_import tr.line_line td.for_title > * {
				display:none;
			}
			
			.for_line select{
				white-space:normal;
				width:300px;
			}
			.ui-dialog {
			    overflow: visible !important;  /* or 'visible' whatever */
			}
		</style>
		
		<script type="text/javascript">
			$(function() {
				var old_type;
				
				$('#to_parse .type select').unbind().click(function() { old_type = $(this).val(); }).change(function() {
					switchClass($(this));
				});
				
				$( "#pop-edit-product-link" ).dialog({
			      modal: true,
			      autoOpen: false,
			      title:"Lier un produit à cette ligne",
			      buttons: {
			        "Lier ce produit": function() {
			        	
			          var fk_product = $('#fk_product_to_link').val() ;
			          var k = $(this).attr('k');	
			          $input = $('tr[k='+k+'] input[rel=fk_product]');
			         //console.log($input);
			         
			          $.ajax({
			          	url:"<?php 
    echo dol_buildpath('/product/ajax/products.php', 1);
    ?>
?action=fetch&id="+fk_product
			          	,dataType:'json'
			          }).done(function(product) {
			          	
			          	$('span[rel="ref-product"][k='+k+']').html(product.ref);
			          	$input.val(fk_product);
			          	console.log(product);
			          	
			          });
			        		
			          $( this ).dialog( "close" );
			        }
			      }
			    });
				
				function switchClass(element)
				{
					var type_value = $(element).val();
	
					if (type_value == 'title') 
					{
						$(element).parent().parent().addClass('liste_titre title_line');
						$(element).parent().parent().removeClass('line_line');
					}
					else 
					{
						$(element).parent().parent().addClass('line_line');
						$(element).parent().parent().removeClass('liste_titre title_line');
						
						if (old_type == 'title' && type_value == 'line')
						{
							while (element.length > 0)
							{
								element = $(element).parent().parent().next().find('td.type').children('select');
								
								if (element.val() == 'title') break;
								
								element.children('option[value=nomenclature]').attr('selected', true);
							}
							
						}
					}
				}
			});
			
			var imp_is_all_check = true;
			function checkAndUncheckAllImport()
			{
				if (imp_is_all_check)
				{
					imp_is_all_check = false;
					$("#to_parse tr .check_imp").attr('checked', false).prop('checked', false);
				}
				else
				{
					imp_is_all_check = true;
					$("#to_parse tr .check_imp").attr('checked', true).prop('checked', true);
				}
			}
			
			function edit_product_link(k) {
				$div = $('#pop-edit-product-link');
				$div.attr('k', k);
				
				$div.dialog('open');
			}
			
		</script>
		<div id="pop-edit-product-link" class="ui-dialog"  >
			<?php 
    $form->select_produits('', 'fk_product_to_link');
    ?>
		</div>
		<table id="table_before_import" width="100%" class="border">
			<tr>
				<td width="25%"><?php 
    echo $langs->trans('Ref');
    ?>
</td>
				<td colspan="3"><div style="vertical-align: middle"><div class="inline-block floatleft refid"><?php 
    echo $object->ref;
    ?>
</div></div></td>
			</tr>
			<tr>
				<td><?php 
    echo $langs->trans('Company');
    ?>
</td>MO-1
				<td colspan="3"><?php 
    echo $object->thirdparty->getNomUrl(1);
    ?>
</td>
			</tr>
			<tr>
				<td colspan="4">
					
						<?php 
    $PDOdb = new TPDOdb();
    $formCore = new TFormCore('auto', 'to_parse', 'post');
    echo $formCore->hidden('action', 'import_data');
    echo $formCore->hidden('id', $object->id);
    echo $formCore->hidden('origin', $origin);
    echo $formCore->hidden('token', $_SESSION['newtoken']);
    echo $formCore->hidden('data', base64_encode(serialize($TData)));
    ?>
							<table class="border" width="100%">
								<tr class="liste_titre">
									<th onclick="javascript:checkAndUncheckAllImport();" style="cursor:pointer;" title="sélectionner/désélectionner tous">Imp.</th>
									<th>Type</th>
									<?php 
    if ($conf->subtotal->enabled) {
        ?>
<th>Niveau</th><?php 
    }
    ?>
									<th>Produit</th>
									<th>Label</th>
									<th>Qté</th>
									<?php 
    if (!empty($conf->global->PRODUCT_USE_UNITS)) {
        ?>
<th>Unité</th><?php 
    }
    ?>
									<th>Prix Achat</th>
									<th>Prix</th>
									<?php 
    if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
        ?>
									<th>Ligne d'origine</th>
									<?php 
    }
    ?>
								</tr>
							<?php 
    if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
        $TPropalDet = array();
        foreach ($object->lines as $line) {
            $label = !empty($line->label) ? $line->label : $line->desc;
            $label .= ' (qté : ' . $line->qty . ', total HT : ' . $line->total_ht . ')';
            $TPropalDet[$line->id] = $label;
        }
    }
    $class = '';
    //var_dump($TData);
    $TWorkstation = TWorkstation::getWorstations($PDOdb);
    foreach ($TData as $k => &$row) {
        //var_dump($row);MO-1
        $workstation = new TWorkstation();
        //var_dump($workstation->loadBy($PDOdb, $row['workstation'], 'code'));
        //var_dump($workstation);exit;
        if (!empty($row['ref'])) {
            $res = $workstation->loadBy($PDOdb, $row['ref'], 'code');
            if ($res > 0) {
                $row['type'] = 'workstation';
                $id_workstation = $workstation->getId();
                //var_dump($workstation);
            }
        }
        $type = $row['type'];
        if ($type == 'title') {
            $class = '';
            print '<tr class="' . $class . ' liste_titre title_line">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            print '<td class="for_title">' . $form->selectarray('TData[' . $k . '][level]', getLevelTitle(), $row['level']) . '</td>';
            print '<td class="for_line">';
            //$form->select_produits(0, 'TData['.$k.'][fk_product]');
            print '</td>';
            print '<td>' . $formCore->texte('', 'TData[' . $k . '][label]', $row['label'], 50, 255) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line"></td>';
            }
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
        } elseif ($type == 'workstation') {
            //var_dump($type);
            $class = '';
            print '<tr class="' . $class . ' workstation_line">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            print '<td></td>';
            print '<td class="for_line">';
            echo $formCore->combo('', 'TData[' . $k . '][fk_workstation]', $TWorkstation, $id_workstation);
            print '</td>';
            print '<td>' . $row['workstation'] . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line"></td>';
            }
            print '<td></td>';
            print '<td></td>';
        } else {
            $class = $class == 'impair' ? 'pair' : 'impair';
            print '<tr class="line_line ' . $class . '" k="' . $k . '">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            if ($conf->subtotal->enabled) {
                print '<td class="for_title">' . $form->selectarray('TData[' . $k . '][level]', getLevelTitle(), $row['level']) . '</td>';
            }
            print '<td class="for_line">';
            if (!empty($row['product_ref'])) {
                $p = new Product($db);
                $p->fetch(null, $row['product_ref']);
                $fk_product = $p->id;
            } else {
                $fk_product = 0;
            }
            print '<span rel="ref-product" k="' . $k . '">' . ($fk_product > 0 ? $p->getNomUrl(1) : 'N/A') . '</span> <a href="javascript:edit_product_link(' . $k . ')">' . img_edit('Changer le produit de destination') . '</a>';
            //$form->select_produits($fk_product, 'TData['.$k.'][fk_product]');
            echo $formCore->hidden('TData[' . $k . '][fk_product]', $fk_product, ' rel="fk_product" ');
            echo $formCore->hidden('TData[' . $k . '][product_ref]', $row['product_ref'], ' rel="product_ref" ');
            print '</td>';
            print '<td>' . $formCore->texte('', 'TData[' . $k . '][label]', $row['label'], 80, 255);
            print '<table>';
            print '<tr>';
            print '<td>Longueur : ' . $formCore->texte('', 'TData[' . $k . '][length]', $row['length'], 15, 255) . '</td>';
            print '<td>Largeur : ' . $formCore->texte('', 'TData[' . $k . '][width]', $row['width'], 15, 255) . '</td>';
            print '<td>Hauteur : ' . $formCore->texte('', 'TData[' . $k . '][height]', $row['height'], 15, 255) . '</td>';
            print '<td>Poids : ' . $formCore->texte('', 'TData[' . $k . '][weight]', $row['weight'], 15, 255) . '</td>';
            print '</tr>';
            print '</table>';
            print '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line">' . $form->selectUnits($row['fk_unit'], 'TData[' . $k . '][fk_unit]', 1) . '</td>';
            }
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][buy_price]', $row['buy_price'], 10, 20) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
        }
        if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
            print '<td class="for_line">' . $form->selectarray('TData[' . $k . '][fk_propaldet]', $TPropalDet, '', 1) . '</td>';
        }
        print '</tr>';
    }
    //exit;
    ?>
							</table>
							<div class="tabsAction">
								<?php 
    echo $langs->trans('DeleteLinesBeforeImport');
    ?>
 <input id="delete_lines_before_import" name="delete_lines_before_import" type="checkbox" value="1" />
								<input class="button" type="submit" value="<?php 
    echo $langs->trans('Import');
    ?>
" />
							</div>
							<?php 
    $formCore->end();
    ?>
				</td>
			</tr>
		</table>
	<?php 
    dol_fiche_end();
    llxFooter();
}