コード例 #1
0
ファイル: SettingsUI.php プロジェクト: Hassanj343/candidats
 public function templateVariables()
 {
     $objRequest=ClsNaanalRequest::getInstance();
     $templatemodule=$objRequest->getData("templatemodule");
     $templateID=$objRequest->getData("templateID");
     if(empty($templatemodule))
     {
         $template="";
         if(!empty($templateID))
         {
             $emailTemplates = new EmailTemplates($this->_siteID);
             $template=$emailTemplates->get($templateID);
             $template["text"]=  $template["text"];
             $template["templatemodule"]=  $template["baseModule"];
         }
         $arrTplVar=array();
         $arrTplVar = $template;
     }
     else
     {
         $arrModule=array();
         $arrModuleTable["candidates"]=array("module"=>"candidate","extra"=>"Candidate");
         $arrModuleTable["joborders"]=array("module"=>"joborder","extra"=>"Joborder");
         $arrModuleTable["contacts"]=array("module"=>"contact","extra"=>"Contact");
         $arrModuleTable["companies"]=array("module"=>"company","extra"=>"Company");
         $arrModuleTable["users"]=array("module"=>"user");
         $arrCandidateParentModule["contacts"]=array("contacts"=>"contacts","companies"=>"companies","users"=>"users");
         $arrCandidateParentModule["joborders"]=array("joborders"=>"joborders","companies"=>"companies","recruiter"=>"users","owner"=>"users");
         $arrCandidateParentModule["candidates"]=array("candidates"=>"candidates","joborders"=>"joborders","companies"=>"companies","users"=>"users");
         $arrTplVar=array();
      
         $allModules=$arrCandidateParentModule[$templatemodule];
         
         if($allModules)
         foreach($allModules as $foreignKey=>$amodule)
         {
             $tableName=$arrModuleTable[$amodule]["module"];
             $extraFieldTableName=isset($arrModuleTable[$amodule]["extra"])?$arrModuleTable[$amodule]["extra"]:"";
             $objDatabase = DatabaseConnection::getInstance();
             $sql="SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '".DATABASE_NAME."' AND TABLE_NAME = '{$tableName}' order by COLUMN_NAME";
             $arrRow=$objDatabase->getAllAssoc($sql);
             $arrMainColumn=array();
             if($arrRow)
             foreach($arrRow as $row)
             {
                 $arrMainColumn[$row["COLUMN_NAME"]]=$row["COLUMN_NAME"];
             }
             asort($arrMainColumn,SORT_STRING);
             $arrTplVar[$foreignKey][$amodule]["main"]=$arrMainColumn;
             $arrExtraColumn=array();
             if($extraFieldTableName)
             {
                 $sql="select extra_field_settings_id,field_name from extra_field_settings left join data_item_type on data_item_type_id=data_item_type where short_description='{$extraFieldTableName}' order by field_name";
                 $arrRow=$objDatabase->getAllAssoc($sql);
                 if($arrRow)
                 foreach($arrRow as $row)
                 {
                     $arrExtraColumn["EXTRA_".$row["field_name"]]=$row["field_name"];
                 }
                 asort($arrExtraColumn,SORT_STRING);
             }
             if($arrExtraColumn)
             {
                 $arrTplVar[$foreignKey][$amodule]["extra"]=$arrExtraColumn;
             }
         }
         $arrTplVar[$foreignKey][$amodule]["other"]["currentTime"]="currentTime";
         if(empty($arrTplVar))
         {
             $arrTplVar=array();
             $arrTplVar["a"]="b";
         }
     }
     echo json_encode($arrTplVar);exit;
 }