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/dev/htdocs/custom/customizeforms/class/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/dev/htdocs/custom/customizeforms/class/actions_customizeforms.class.php
<?php
/*  Copyright (C) 2019 Customizeforms Paulo Ricardo Carvalho de Oliveira	<paulorcdo@gmail.com>
 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

 
dol_include_once('/core/lib/functions.lib.php');

$res=@dol_include_once('/customizeforms/lib/customizeinterface.php');// For root directory
$custom=0;

if (! $res)
{
$res=@dol_include_once('/custom/customizeforms/lib/customizeinterface.php'); // For "custom" directory
$custom=0;

}

 
 
/**
 * Class Actionscustomizeforms
 */
class ActionsCustomizeForms
{
    /**
     * @var DoliDB Database handler
     */
    private $db;

    /**
     * @var string HTML displayed as a result of hook call
     */
    public $resprints;
    public  $javascript;
    /**
     *  Constructor
     *
     * @param DoliDB $db Database handler
     */
    public function __construct($db)
    {
        $this->db = $db;
    }

    /**
     * Get Google locale matching Dolibarr language
     *
     * @return string Google equivalent locale
     */
   
    
  public  function printTabsHead($parameters, $object, &$action)
{
   global $db,$user,$langs ;
   
     
     
$cf= new Customizeconfig($db,TRUE);
$cf->get_customization();

$retorno=$cf->response;


$tex="";

$tex.="
//habilita";
for ($i=0;$i<count($retorno['sit1']);$i++)
{
    
        if($retorno['sit1'][$i][1]=="cabecalho")
        {
        $tex.="
        $('<tr><td><label for=".$retorno['sit1'][$i][1].">".$langs->trans('Header')."</label></td><td colspan=3><div name=".$retorno['sit1'][$i][1]." id=".$retorno['sit1'][$i][1]."></div></td></tr>').insertBefore('table.border > tbody > tr:first')";
        }
        
        elseif($retorno['sit1'][$i][1]=="rodape")
        {
        $tex.="
        $('<tr><td><label for=".$retorno['sit1'][$i][1].">".$langs->trans('Footer')."</label></td><td colspan=3><div name=".$retorno['sit1'][$i][1]." id=".$retorno['sit1'][$i][1]."></div></td></tr>').insertAfter('table.border > tbody > tr:last')";
        }
        
}

$tex.="

//desabilita";    

for ($i=0;$i<count($retorno['sit2']);$i++)
{
    if($retorno['sit2'][$i][4]==1)
    {
     
           if($retorno['sit2'][$i][2]=='chkbxlst'||$retorno['sit2'][$i][2]=='checkbox')
        {
           
            $nome='options_'.$retorno['sit2'][$i][1]."[]";
        
        }
        else{
            
            $nome='options_'.$retorno['sit2'][$i][1];
            }
      
    }
    else
    {
        
         if($retorno['sit2'][$i][1]=='commercial'||$retorno['sit2'][$i][1]=='suppcats'||$retorno['sit2'][$i][1]=='custcats'||$retorno['sit2'][$i][1]=='contcats'||$retorno['sit2'][$i][1]=='usercats'||$retorno['sit2'][$i][1]=='memcats'||$retorno['sit2'][$i][1]=='categories'||$retorno['sit2'][$i][1]=='socpeopleassigned'  )
        {
          
            $nome=$retorno['sit2'][$i][1]."[]";
            
        }
        else
        {
          
            $nome=$retorno['sit2'][$i][1];
            }
   }

    
$tex.="
$(\"[name='".$nome."']\").prop('disabled', true);";   
}
   
$tex.="
//label";

for ($i=0;$i<count($retorno['lab']);$i++)
{
    if($retorno['lab'][$i][4]==1)
    {
     
           if($retorno['lab'][$i][2]=='chkbxlst'||$retorno['lab'][$i][2]=='checkbox')
        {
           
            $nome='options_'.$retorno['lab'][$i][1]."[]";
        
        }
        else{
            
            $nome='options_'.$retorno['lab'][$i][1];
            }
      
    }
    else
    {
        
         if($retorno['lab'][$i][1]=='commercial'||$retorno['lab'][$i][1]=='suppcats'||$retorno['lab'][$i][1]=='custcats'||$retorno['lab'][$i][1]=='contcats'||$retorno['lab'][$i][1]=='usercats'||$retorno['lab'][$i][1]=='memcats'||$retorno['lab'][$i][1]=='categories'||$retorno['lab'][$i][1]=='socpeopleassigned'  )
        {
          
            $nome=$retorno['lab'][$i][1]."[]";
            
        }
        else
        {
          
            $nome=$retorno['lab'][$i][1];
            }
   }
          
    if((($retorno['lab'][$i][1]=="effectif_id"||$retorno['lab'][$i][1]=="town"||$retorno['lab'][$i][1]=="fax"||$retorno['lab'][$i][1]=="idprof3"||$retorno['lab'][$i][1]=="idprof5"||$retorno['lab'][$i][1]=="tva_intra")&&$retorno['lab'][$i][6]=='NewThirdParty')||(($retorno['lab'][$i][1]=="phone_perso"||$retorno['lab'][$i][1]=="fax" )&&$retorno['lab'][$i][6]=='AddContact')||(($retorno['lab'][$i][1]=="barcode"||$retorno['lab'][$i][1]=="desiredstock")&&$retorno['lab'][$i][6]=='NewProduct-NewService'))
    
    
    
         {
        $tex.="
$(\"[name='".$nome."']\").closest('tr').children('td:nth-child(3)').replaceWith('<td>".$retorno['lab'][$i][5]."</td>');" ; 
    

} 
        elseif(($retorno['lab'][$i][1]=="customer_code"||$retorno['lab'][$i][1]=="supplier_code"||$retorno['lab'][$i][1]=="supplier_code"||$retorno['lab'][$i][1]=="birthday_alert")&&$retorno['lab'][$i][6]=='NewThirdParty')
         {
        $tex.="
$(\"[name='".$nome."']\").closest('table').closest('tr').children('td:nth-child(3)').replaceWith('<td>".$retorno['lab'][$i][5]."</td>');" ; 
    

} 

         elseif(($retorno['lab'][$i][1]=="birthday_alert")&&$retorno['lab'][$i][6]=='AddContact')
         {
        $tex.="
   $(\"label[for='".$nome."']\").replaceWith('".$retorno['lab'][$i][5]."');" ;
 
    

} 

 
        else      
          {
        $tex.="
$(\"[name='".$nome."']\").closest('tr').children('td:first').replaceWith('<td>".$retorno['lab'][$i][5]."</td>');" ; 

}


// else
//  {
//         $tex.="
// $(\"[name='".$nome."']\").closest('tr').children('td:nth-child(3)').replaceWith('<td>".$retorno['lab'][$i][5]."</td>');" ; 
    

// }

 
}
   
$tex.="

//obrigatorio";     
for ($i=0;$i<count($retorno['sit3']);$i++)
{
    if($retorno['sit3'][$i][4]==1)
    {
      
           if($retorno['sit3'][$i][2]=='chkbxlst'||$retorno['sit3'][$i][2]=='checkbox')
        {

            $nome='options_'.$retorno['sit3'][$i][1]."[]";
            
        }
        
        else{
             
             $nome='options_'.$retorno['sit3'][$i][1];
            }
      
    }
    else
    {
        
         if($retorno['sit3'][$i][1]=='commercial'||$retorno['sit3'][$i][1]=='suppcats'||$retorno['sit3'][$i][1]=='custcats'||$retorno['sit3'][$i][1]=='contcats'||$retorno['sit3'][$i][1]=='usercats'||$retorno['sit3'][$i][1]=='memcats'||$retorno['sit3'][$i][1]=='categories'||$retorno['sit3'][$i][1]=='socpeopleassigned'  )
        {
          
            $nome=$retorno['sit3'][$i][1]."[]";
            
        }
        else
        {
           
            $nome=$retorno['sit3'][$i][1];
            }
   }
          
    
$tex.="

$(\"[name='".$nome."']\").closest('tr').children('td:first').addClass('fieldrequired');

$(\"form\").on(\"submit\", function() {
 

if(($(\"[name='".$nome."']\").val()<1)||($(\"[name='".$nome."']\").value=''))
{
alert('".html_entity_decode($langs->trans('Campo')).' '.html_entity_decode($langs->trans('Mandatory')).': '.html_entity_decode($langs->trans($retorno['sit3'][$i][3]))."');
   $(\"[name='".$nome."']\").focus();
  return false;
  }
  else
  {
  
  return true;
  }
   
});

";

}
  

$tex.="

//valor padrao";

for ($i=0;$i<count($retorno['vp']);$i++)
{
    if($retorno['vp'][$i][4]==1)
    {
     
           if($retorno['vp'][$i][2]=='chkbxlst'||$retorno['vp'][$i][2]=='checkbox')
        {
           
            $nome='options_'.$retorno['vp'][$i][1]."[]";
        
        }
        else{
            
            $nome='options_'.$retorno['vp'][$i][1];
            }
      
    }
    else
    {
        
         if($retorno['vp'][$i][1]=='commercial'||$retorno['vp'][$i][1]=='suppcats'||$retorno['vp'][$i][1]=='custcats'||$retorno['vp'][$i][1]=='contcats'||$retorno['vp'][$i][1]=='usercats'||$retorno['vp'][$i][1]=='memcats'||$retorno['vp'][$i][1]=='categories'||$retorno['vp'][$i][1]=='socpeopleassigned'  )
        {
          
            $nome=$retorno['vp'][$i][1]."[]";
            
        }
        else
        {
          
            $nome=$retorno['vp'][$i][1];
            }
   }
          
    $valor=explode(",",$retorno['vp'][$i][5]);
    if(count($valor)>1&&$nome!='cabecalho'&&$nome!='rodape')
    {
    
$tex.="
values='".$retorno['vp'][$i][5]."';
$(\"[name='".$nome."']\").val(values.split(','))" ;
}
else
{
    if($nome!='photo')
    {
    if($nome=='cabecalho'||$nome=='rodape'||$nome=='signature'||$retorno['vp'][$i][2]=='html')
    {
   $tex.="
$(\"[name='".$nome."']\").html('".preg_replace( '/\r\n/', '',$retorno['vp'][$i][5])."')";
}
else
{
    
    
            if($nome=='duration_unit'||$nome=='type' ||$retorno['vp'][$i][2]=='radio'||$retorno['vp'][$i][2]=='boolean')
            {
             
            $tex.="          
$(\"[name='".$nome."']\").val(['".$retorno['vp'][$i][5]."']);";
             }
              elseif($nome=='birthday_alert'||$nome=='fullday'||$nome=='usage_opportunity'||$nome=='usage_task'||$nome=='usage_bill_time')
            {
             
            $tex.="          
$(\"[name='".$nome."']\").attr('checked', 'checked');";
             }
             else
             {
             
              $tex.="
$(\"[name='".$nome."']\").val('".$retorno['vp'][$i][5]."');";
             }
    }

    }
    }
    $text =0;
    if(substr($retorno['vp'][$i][5], 0, 4)=='now(')
    {
 
    if( preg_match( '!\(([^\)]+)\)!', $retorno['vp'][$i][5], $match ) )
    $text =($match[1]?$match[1]:0);
 

    if(!is_null($text))
    {
        if($text==0)
        {
             $tex.="  
          programado=new Date(Date.now());
             $(\"#".$nome."\").val(programado.toLocaleDateString());
             ";  
        }
        else
        {
               $tex.="  
          programado=new Date(Date.now() + 1000 /*sec*/ * 60 /*min*/ * 60 /*hour*/ * 24 /*day*/ ".($text?'*':'')." ".($text?$text:'').");
             $(\"#".$nome."\").val(programado.toLocaleDateString());
             ";
        }
             
       
             
                  if($nome=="re"||$nome=="ap"||$nome=="p2"||$nome=="liv_"||$nome=="ech"||$nome=="dateofbirth"||$nome=="dateofbirth"||$nome=="dateemployment"||$nome=="dateemploymentend"||$nome=="datestartvalidity"||$nome=="dateendvalidity"||$nome=="projectstart" ||$nome=="projectend"  ||$nome=="datep"  ||$nome=="datev"  ||$nome=="datesp"  ||$nome=="dateep"  ||$nome=="dateo" ||$nome=="datee" )
             {
             $tex.="  
 
   dia=programado.getDate();
             $(\"#".$nome."day\").val(dia<10?'0'+dia:dia);
             mes=programado.getMonth()+1;
                $(\"#".$nome."month\").val(mes<10?'0'+mes:mes);
                   $(\"#".$nome."year\").val(programado.getFullYear());
             ";   
             }        
             
                 
             
             
    }
    else
    {
         $tex.="    $(\"#".$nome."ButtonNow\").click();";
    }
  
    
 
  

 
    }
    
//($nome=='cabecalho'||$nome=='rodape'?'text':'val')

}

 
$tex.="

//tooltip";

for ($i=0;$i<count($retorno['too']);$i++)
{
    if($retorno['too'][$i][4]==1)
    {
     
           if($retorno['too'][$i][2]=='chkbxlst'||$retorno['too'][$i][2]=='checkbox' )
        {
           
            $nome='options_'.$retorno['too'][$i][1]."[]";
            $tipo='select';
        
        }
           elseif($retorno['too'][$i][2]=='link' ||$retorno['too'][$i][2]=='sellist' ||$retorno['too'][$i][2]=='select'  )
        {
           
         $nome='options_'.$retorno['too'][$i][1];
            $tipo='select';
        
        }
       
           elseif($retorno['too'][$i][2]=='text'||$retorno['too'][$i][2]=='html')
        {
           
         $nome='options_'.$retorno['too'][$i][1];
            $tipo='textarea';
        
        } 
        else{
            
            $nome='options_'.$retorno['too'][$i][1];
            $tipo='input';
            
            }
      
    }
    else
    {
        
         if($retorno['too'][$i][1]=='commercial'||$retorno['too'][$i][1]=='suppcats'||$retorno['too'][$i][1]=='custcats'||$retorno['too'][$i][1]=='contcats'||$retorno['too'][$i][1]=='usercats'||$retorno['too'][$i][1]=='memcats'||$retorno['too'][$i][1]=='categories'||$retorno['too'][$i][1]=='socpeopleassigned'  )
        {
          
            $nome=$retorno['too'][$i][1]."[]";
             $tipo=$retorno['too'][$i][2];
        }
        else
        {
          
            $nome=$retorno['too'][$i][1];
             $tipo=$retorno['too'][$i][2];
            }
   }
          
 
    
    
    $tooltip="<span class=\"classfortooltip fa fa-question-circle \" title=\'".preg_replace( '/\r|\n/', '',$retorno['too'][$i][5])."\' ></span>";
   $tex.="
$(\"".$tipo."[name='".$nome."']\").before('&nbsp;".$tooltip."&nbsp;&nbsp;');
";
  
}     

$tex.="

//conteudo";

for ($i=0;$i<count($retorno['con']);$i++)
{
    if($retorno['con'][$i][4]==1)
    {
     
           if($retorno['con'][$i][2]=='chkbxlst'||$retorno['con'][$i][2]=='checkbox')
        {
           
            $nome='options_'.$retorno['con'][$i][1]."[]";
        
        }
        else{
            
            $nome='options_'.$retorno['con'][$i][1];
            }
      
    }
    else
    {
        
         if($retorno['con'][$i][1]=='commercial'||$retorno['con'][$i][1]=='suppcats'||$retorno['con'][$i][1]=='custcats'||$retorno['con'][$i][1]=='contcats'||$retorno['con'][$i][1]=='usercats'||$retorno['con'][$i][1]=='memcats'||$retorno['con'][$i][1]=='categories'||$retorno['con'][$i][1]=='socpeopleassigned'  )
        {
          
            $nome=$retorno['con'][$i][1]."[]";
            
        }
        else
        {
          
            $nome=$retorno['con'][$i][1];
            }
   }
  
      
      
   $lista0=preg_replace( '/\'/', '\\\'',$retorno['con'][$i][5]);
   $lista0=preg_replace( '/\"/', '\\\'',$lista0);          
    $lista=preg_replace( '/\r\n/', '||',$lista0);
    
    if($retorno['con'][$i][1]=="note_public"||$retorno['con'][$i][1]=="note_private"||$retorno['con'][$i][2]=="html"||$retorno['con'][$i][1]=="bodyemail"||$retorno['con'][$i][1]=="desc" ||$retorno['con'][$i][1]=="account_comment"||$retorno['con'][$i][1]=="note"||$retorno['con'][$i][1]=="signature" )
     {
           $combo="<select onchange=CKEDITOR.instances.".$nome.".setData($(\"[name=\'sel_".$nome."\']\").val()); class=\"maxwidthsearch\" style=\"background-color:#ffebcc\" name=\"sel_".$nome."\" >"; 
        
        }
        
        else
        {
    $combo="<select onchange=$(\"[name=\'".$nome."\']\").val($(\"[name=\'sel_".$nome."\']\").val()); class=\"maxwidthsearch\" style=\"background-color:#ffebcc\" name=\"sel_".$nome."\" >";
    
    }
    $combo_options=explode("||",$lista);
   
        
          $combo.="<option value=\"\">&nbsp;</option>"; 
        
for ($x=0;$x<count($combo_options);$x++)
{
        $combo.="<option value=\"".$combo_options[$x]."\">".$combo_options[$x]."</option>";
        
  }
    $combo.="</select><br> ";
     
   $tex.="
   
   
$(\"[name='".$nome."']\").before('".$combo."');";
 
    
 

}

$tex.="
//invisivel";

for ($i=0;$i<count($retorno['sit0']);$i++)
{

$idtag = $retorno['sit0'][$i][3];
if($retorno['sit0'][$i][1]!='rodape'&&$retorno['sit0'][$i][1]!='cabecalho')
{
    
    if($retorno['sit0'][$i][4]==1){
        if($retorno['sit0'][$i][2]=='chkbxlst'||$retorno['sit0'][$i][2]=='checkbox')
        {   
            $nome='options_'.$retorno['sit0'][$i][1]."[]";
        }else{
            $nome='options_'.$retorno['sit0'][$i][1];
        }
    }else{
        
        if($retorno['sit0'][$i][1]=='commercial'||$retorno['sit0'][$i][1]=='suppcats'||$retorno['sit0'][$i][1]=='custcats'||$retorno['sit0'][$i][1]=='contcats'||$retorno['sit0'][$i][1]=='usercats'||$retorno['sit0'][$i][1]=='memcats'||$retorno['sit0'][$i][1]=='categories'||$retorno['sit0'][$i][1]=='socpeopleassigned'  )
        {  
            $nome=$retorno['sit0'][$i][1]."[]";    
        }else{
            $nome=$retorno['sit0'][$i][1];
        }
    }
    if(($retorno['sit0'][$i][1]=="idprof2"&&$retorno['sit0'][$i+1][1]=="idprof3")&&$retorno['sit0'][$i][6]=='NewThirdParty')
    {
$tex.="
$(\"[name='".$nome."']\").closest('tr').hide();
";
    }elseif(($retorno['sit0'][$i][1]=="idprof4"&&$retorno['sit0'][$i+1][1]=="idprof5")&&$retorno['sit0'][$i][6]=='NewThirdParty'){
$tex.="
$(\"[name='".$nome."']\").closest('tr').hide();
";

    }elseif((($retorno['sit0'][$i][1]=="effectif_id"||$retorno['sit0'][$i][1]=="town"||$retorno['sit0'][$i][1]=="fax"||$retorno['sit0'][$i][1]=="idprof3"||$retorno['sit0'][$i][1]=="idprof5"||$retorno['sit0'][$i][1]=="tva_intra")&&$retorno['sit0'][$i][6]=='NewThirdParty')||(($retorno['sit0'][$i][1]=="phone_perso"||$retorno['sit0'][$i][1]=="fax"||$retorno['sit0'][$i][1]=="birthday_alert")&&$retorno['sit0'][$i][6]=='AddContact')||(($retorno['sit0'][$i][1]=="barcode"||$retorno['sit0'][$i][1]=="desiredstock" )&&$retorno['sit0'][$i][6]=='NewProduct-NewService')){
        $tex.="
        
$(\"[name='".$nome."']\").closest('tr').children('td:nth-child(3)').hide(); 
$(\"[name='".$nome."']\").closest('tr').children('td:nth-child(4)').hide();

" ;
    }elseif((($retorno['sit0'][$i][1]=="typent_id"||$retorno['sit0'][$i][1]=="idprof2"||$retorno['sit0'][$i][1]=="idprof4" ||$retorno['sit0'][$i][1]=="zipcode"||$retorno['sit0'][$i][1]=="fournisseur"||$retorno['sit0'][$i][1]=="client")&&$retorno['sit0'][$i][6]=='NewThirdParty')||(($retorno['sit0'][$i][1]=="phone_pro"||$retorno['sit0'][$i][1]=="phone_mobile"||$retorno['sit0'][$i][1]=="birthday" )&&$retorno['sit0'][$i][6]=='AddContact')||(($retorno['sit0'][$i][1]=="fk_barcode_type"||$retorno['sit0'][$i][1]=="seuil_stock_alerte"||$retorno['sit0'][$i][1]=="customcode")&&$retorno['sit0'][$i][6]=='NewProduct-NewService')){
        $tex.="
        
$(\"[name='".$nome."']\").closest('tr').children('td:nth-child(1)').hide(); 
$(\"[name='".$nome."']\").closest('tr').children('td:nth-child(2)').hide();

" ;
    }elseif(($retorno['sit0'][$i][1]=="customer_code"||$retorno['sit0'][$i][1]=="supplier_code"||$retorno['sit0'][$i][1]=="supplier_code")&&$retorno['sit0'][$i][6]=='NewThirdParty'){
        $tex.="
$(\"[name='".$nome."']\").closest('table').closest('tr').children('td:nth-child(3)').hide();
$(\"[name='".$nome."']\").closest('table').closest('tr').children('td:nth-child(4)').hide();
" ; 
    

    }elseif((($retorno['sit0'][$i][1]=="typent_id"||$retorno['sit0'][$i][1]=="idprof2"||$retorno['sit0'][$i][1]=="idprof4" ||$retorno['sit0'][$i][1]=="zipcode"||$retorno['sit0'][$i][1]=="fournisseur"||$retorno['sit0'][$i][1]=="client")&&$retorno['sit0'][$i][6]=='NewThirdParty')||(($retorno['sit0'][$i][1]=="phone_pro"||$retorno['sit0'][$i][1]=="phone_mobile"||$retorno['sit0'][$i][1]=="birthday" )&&$retorno['sit0'][$i][6]=='AddContact')||(($retorno['sit0'][$i][1]=="fk_barcode_type"||$retorno['sit0'][$i][1]=="seuil_stock_alerte"||$retorno['sit0'][$i][1]=="customcode")&&$retorno['sit0'][$i][6]=='NewProduct-NewService')){
        $tex.="
        
$(\"[name='".$nome."']\").closest('tr').children('td:nth-child(1)').hide(); 
$(\"[name='".$nome."']\").closest('tr').children('td:nth-child(2)').hide();

" ;
}else{   
      
$tex.="
$(\"[name='".$nome."']\").closest('tr').hide();";

} 

$tex.="
$(\"[id='".$idtag."']\").closest('tr').hide();";


}
}

  
  $javascript="
  <script language=javascript>
  
                    
function ocultacampos()
{  
 


". $tex."



 
  

   
 

 
 
}
$(document).ready(function() {
ocultacampos();
 });
</script>

";
 	 $this->resprints .=  $parameters['out'].$javascript;
 

 
 	return 1;
}
}

Hry