protected static function queryConditionJobCategoryId($jobCategoryId)
 {
     /* Only jobSubCategory IDs available in the job table, so have to retrieve them from the jobSubCaterogy table */
     $jobSubCategoryRows = JobSubCategory::getJobSubCategoryList($jobCategoryId);
     $jobSubCategoryList = "";
     while (($jobSubCategoryRow = $jobSubCategoryRows->fetch_row()) != NULL) {
         $jobSubCategoryList .= JobSubCategory::getJobSubCategoryId($jobSubCategoryRow) . ", ";
     }
     $condition = "";
     if (!empty($jobSubCategoryList)) {
         $jobSubCategoryList = substr($jobSubCategoryList, 0, -strlen(", "));
         $condition = "`subcategory_id` IN ({$jobSubCategoryList})";
     }
     return $condition;
 }
 protected function jsJobSubCategoryUpdate()
 {
     $output = "";
     /* create the jobCategory <-> jobSubCategory connection */
     $output .= "var jobSubCategoryNames = new Array();\n";
     $output .= "var jobSubCategoryIds = new Array();\n";
     $output .= "jobSubCategoryNames[" . static::anyJobCategoryCode . "] = [\"Select job category first\"];\n";
     $output .= "jobSubCategoryIds[" . static::anyJobCategoryCode . "] = [\"" . static::anyJobSubCategoryCode . "\"];\n";
     $jobCategoryList = JobCategory::getAllRows();
     $jobCategoryCount = 0;
     while (($jobCategory = $jobCategoryList->fetch_row()) != NULL) {
         $jobCategoryId = JobCategory::getJobCategoryId($jobCategory);
         $jobSubCategoryList = JobSubCategory::getJobSubCategoryList($jobCategoryId);
         /* first the jobSubCategory names */
         $output .= "jobSubCategoryNames[{$jobCategoryId}] = [\"Any job sub category\"";
         while (($jobSubCategory = $jobSubCategoryList->fetch_row()) != NULL) {
             $output .= ", \"" . JobSubCategory::getJobSubCategoryName($jobSubCategory) . "\"";
         }
         $output .= "];\n";
         /* then the jobSubCategory Ids */
         $output .= "jobSubCategoryIds[{$jobCategoryId}] = [\"" . static::anyJobSubCategoryCode . "\"";
         $jobSubCategoryList->data_seek(0);
         while (($jobSubCategory = $jobSubCategoryList->fetch_row()) != NULL) {
             $output .= ", \"" . JobSubCategory::getJobSubCategoryId($jobSubCategory) . "\"";
         }
         $output .= "];\n";
     }
     /* print the jobSubCategoryUpdate() function */
     /* the below code is JavaScript */
     $output .= "\n";
     $output .= "jobSubCategoryList = document." . static::formName . "." . static::jobSubCategoryIdFieldName . ";\n";
     $output .= "function jobSubCategoryUpdate(selectedJobCategoryId){\n";
     $output .= " jobSubCategoryList.options.length = 0;\n";
     $output .= " for (i=0; i < jobSubCategoryNames[selectedJobCategoryId].length; i++) {\n";
     $output .= "      jobSubCategoryList.options[jobSubCategoryList.options.length] = new Option(jobSubCategoryNames[selectedJobCategoryId][i],jobSubCategoryIds[selectedJobCategoryId][i]);\n";
     $output .= " }\n";
     $output .= "}\n";
     return $output;
 }