Heray-Was-Here
Server : Apache
System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.2.31
Disable Function : NONE
Directory :  /var/www/erp/htdocs/custom/paiedolibarr/rules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/erp/htdocs/custom/paiedolibarr/rules/create.php
<?php

if ($action == 'create' && $request_method === 'POST') {

    global $conf;

    $code = GETPOST('code', 'aZ09');
    if(!$code){
        $error++;
        setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("paieCode")), null, 'errors');
        header('Location: ./card.php?action=add');
        exit;
    }

    $data = array();
    $data['code']               = strtoupper($code);
    $data['entity']             = $conf->entity;
    $data['label']              = addslashes(GETPOST('label'));
    $data['amounttype']         = trim(GETPOST('amounttype'));
    $data['category']           = GETPOST('category');
    
    if($data['amounttype'] == 'FIX'){
        $data['amount']         = price2num(GETPOST('amount', 'alpha'), '', 2);
    }else{
        $formule = trim(GETPOST('formule'));
        $formule = str_replace("%", "/100", $formule);
        $data['formule'] = $formule;
    }

    $avance = $object->create(1,$data);
    $object->fetch($avance);
   
    if ($avance > 0) {
        header('Location: ./card.php?id='. $avance);
        exit;
    }
    else {
        setEventMessages($object->errors, null, 'errors');
        header('Location: card.php?action=add');
        exit;
    }
}

if($action == "add"){

    global $conf;
    print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" class="competcpaiedolibarr card_paiedolibarr">';
    print '<input type="hidden" name="token" value="'.newToken().'">';
    print '<input type="hidden" name="action" value="create" />';
    print '<input type="hidden" name="page" value="'.$page.'" />';
    print '<table class="border dstable_" width="100%">';
    print '<tbody>';

    print '<tr>';
        print '<td class="titlefieldcreate">'.$langs->trans('paieCode').'</td>';
        print '<td ><input type="text" class="minwidth300 codepaie" id="code" name="code" value=""/>';
        print '</td>';
    print '</tr>';
    
    print '<tr>';
        print '<td class="titlefieldcreate">'.$langs->trans('paieDesignation').'</td>';
        print '<td ><input type="text" class="minwidth300" id="label" name="label" value=""/>';
        print '</td>';
    print '</tr>';

    print '<tr>';
        print '<td class="titlefieldcreate">'.$langs->trans('paieCategorie').'</td>';
        print '<td>';
        print $paies->selectCategories('', 'category', 0, false);
        print '</td>';
    print '</tr>';

    print '<tr class="baseamount">';
        print '<td>'.$langs->trans('Type').'</td>';
        print '<td>';
        print '<span class="amounttype">';
        print $object->selectAmounttype('CALCULATED', 'amounttype', 0);
        print '</span>';
        print '</td>';
    print '</tr>';

    $discss = '';
    print '<tr class="baseamountfix" '.$discss.'>';
        print '<td>'.$langs->trans('paieTotal').'</td>';
        print '<td>';
        print '<input type="number" step="0.01" class="minwidth50" id="amount" name="amount"  value="0"/>';
        print '</td>';
    print '</tr>';

    print '<tr class="baseamountcalculated" '.$discss.'>';
        print '<td>'.$langs->trans('paieForm').'</td>';
        // print '<td>';
        // print '<input type="text" class="width100percent" id="formule" name="formule" placeholder="0.04 * (SALAIRE_BASE)" value=""/>';
        // print '</td>';
        print '<td><textarea name="formule" id="formule" class="centpercent" rows="4" placeholder="0.04 * (SALAIRE_BASE)">';
        print '</textarea></td>';
    print '</tr>';

    print '</tbody>';
    print '</table>';

    print '<br>';

    print '<div class="baseamountcalculated" '.$discss.'>';
        $helpsubstit = $paies->getAvailableSubstitKey();
        echo $helpsubstit;
    print '</div>';
    
    // Actions
    print '<br>';
    print '<table class="" width="100%">';
    print '<tr>';
        print '<td colspan="2" align="center" >';
        print '<br>';
        print '<input type="submit" class="button" name="save" value="'.$langs->trans('Validate').'">';
        print '<input type="button" class="button" value="'.$langs->trans('Cancel').'" onclick="javascript:history.go(-1)">';
    print '</tr>';
    print '</table>';


    print '</form>';

}

Hry