Внутренняя ошибка сервера PHPWord
Я пытаюсь решить одну проблему из-за очень долгого времени.. Мой Документ PhpWord загружается должным образом в localhost, но я не получаю точный вывод.. Мое слово печатает тег напрямую, не делая его сильным. Тот же файл, когда я запускаю его на своем тестовом сервере, я получаю внутреннюю ошибку сервера 500.. Пожалуйста, помогите мне.. Ниже приведен код
function download($id, $letterName) {
$a_json = array ();
if(!$letterName)
die(false);
$this->getHtml();
switch($letterName){
case "Evaluation:Transfer":
$query = "SELECT CONCAT(wrk.employee_name,' ',wrk.employee_lastname) employee_name,
br.branch_name new_branch,
oldBr.branch_name old_branch,oldBr.branch_name branch_name,cde.department_name department_name,cd.designation_name designation_name,wrk.employee_id,DATE_FORMAT(ct.action_effects_from,'%d-%m-%Y') doj,ct.affected_ids affectedIds
FROM employee_work_details wrk
INNER JOIN company_branch br
ON wrk.branch_id = br.branch_id
INNER JOIN emp_branch_history brHist
ON wrk.employee_id = brHist.employee_id AND brHist.effects_upto = DATE_SUB( wrk.branch_effects_from , INTERVAL 1 DAY)
INNER JOIN company_branch oldBr
ON brHist.branch_id = oldBr.branch_id
LEFT JOIN company_designations cd
ON wrk.designation_id = cd.designation_id
LEFT JOIN company_departments cde
ON wrk.department_id = cde.department_id
INNER JOIN comp_transfers ct
ON wrk.transfer_id = ct.action_id
WHERE wrk.transfer_id = '$id' AND wrk.enabled=1 ";
break;
case "Evaluation:Promotion":
$query = "SELECT CONCAT(wd.employee_name,' ',wd.employee_lastname) employee_name,desg.designation_name designation,
oldesg.designation_name old_designation,cb.branch_name,cd.department_name,
DATE_FORMAT(pro.action_effects_from,'%d-%m-%Y') effective_from,wd.employee_id,pro.affected_ids affectedIds,c.company_name
FROM employee_work_details wd
INNER JOIN company_designations desg
ON wd.designation_id = desg.designation_id
INNER JOIN company_branch cb
ON wd.branch_id = cb.branch_id
INNER JOIN company_departments cd
ON wd.department_id = cd.department_id
INNER JOIN company_details c
ON c.company_id = '" . $_SESSION ['company_id'] . "'
INNER JOIN comp_promotions_increments pro
ON wd.promotion_id = pro.action_id
INNER JOIN emp_designation_history desHis
ON wd.employee_id = desHis.employee_id AND desHis.effects_upto = DATE_SUB(wd.design_effects_from,INTERVAL 1 DAY)
INNER JOIN company_designations oldesg ON oldesg.designation_id = desHis.designation_id
WHERE wd.promotion_id='$id' AND wd.enabled=1";
break;
case "Evaluation:Promotion come Increment":
$query = "SELECT CONCAT(wd.employee_name,'',wd.employee_lastname) employee_name,desg.designation_name designation,
oldesg.designation_name old_designation,pro.incremented_amount increment_percentage,sh.employee_salary_amount old_salary,s.employee_salary_amount new_salary,cb.branch_name,cd.department_name,
DATE_FORMAT(pro.action_effects_from,'%d-%m-%Y') effective_from,wd.employee_id,pro.affected_ids affectedIds
FROM employee_work_details wd
INNER JOIN company_designations desg
ON wd.designation_id = desg.designation_id
INNER JOIN company_branch cb
ON wd.branch_id = cb.branch_id
INNER JOIN company_departments cd
ON wd.department_id = cd.department_id
INNER JOIN employee_salary_details s
ON wd.employee_id = s.employee_id
INNER JOIN employee_salary_details_history sh
ON wd.employee_id = sh.employee_id AND sh.effects_upto = DATE_SUB(s.effects_from,INTERVAL 1 DAY)
INNER JOIN comp_promotions_increments pro
ON wd.promotion_id = pro.action_id
INNER JOIN emp_designation_history desHis
ON wd.employee_id = desHis.employee_id AND desHis.effects_upto = DATE_SUB(wd.design_effects_from,INTERVAL 1 DAY)
INNER JOIN company_designations oldesg ON oldesg.designation_id = desHis.designation_id
WHERE wd.promotion_id='$id' AND wd.enabled=1 ";
break;
case "Evaluation:Increment":
$query = "SELECT CONCAT(w.employee_name,'',w.employee_lastname) employee_name,desg.designation_name designation,
pro.incremented_amount increment_percentage,sh.employee_salary_amount old_salary,s.employee_salary_amount new_salary,
cb.branch_name,cd.department_name,w.employee_id,pro.affected_ids affectedIds,DATE_FORMAT(pro.action_effects_from,'%d-%m-%Y') effective_from,c.company_name
FROM employee_work_details w
INNER JOIN employee_salary_details s
ON w.employee_id = s.employee_id
INNER JOIN employee_salary_details_history sh
ON w.employee_id = sh.employee_id AND sh.effects_upto = DATE_SUB(s.effects_from, INTERVAL 1 DAY)
INNER JOIN company_designations desg
ON w.designation_id = desg.designation_id
INNER JOIN company_branch cb
ON w.branch_id = cb.branch_id
INNER JOIN company_departments cd
ON w.department_id = cd.department_id
INNER JOIN company_details c
ON c.company_id = '" . $_SESSION ['company_id'] . "'
INNER JOIN comp_promotions_increments pro
ON s.increment_id = pro.action_id
WHERE s.increment_id = '$id' AND w.enabled = 1;";
break;
case "Offer:Confirmation":
$query ="SELECT w.employee_id,CONCAT(w.employee_name,' ',w.employee_lastname) employee_name,w.employee_doj doj,des.designation_name designation,
dep.department_name department,DATE_FORMAT(s.effects_from,'%d-%m-%Y') effect_from,s.employee_salary_amount salary,CONCAT(w.employee_probation_period/30,' ','months') months,cd.company_name
FROM employee_work_details w
INNER JOIN employee_salary_details s
ON w.employee_id = s.employee_id
INNER JOIN company_designations des
ON w.designation_id = des.designation_id
INNER JOIN company_departments dep
ON w.department_id = dep.department_id
INNER JOIN company_branch b
ON w.branch_id = b.branch_id
INNER JOIN company_details cd
ON cd.company_id = '" . $_SESSION ['company_id'] . "'
WHERE w.employee_id = '$id'";
break;
default:
die("No Letter Found");
}
$result = mysqli_query ( $this->conn, $query ) or die(mysqli_error($this->conn));
$letter = new letterTemplate($this->letterContent);
$filename = str_replace ( ' ', '', $letterName );
$PHPWord = new PHPWord ();
$count =0;
while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) {
$affectedIds = $row ['affectedIds'];
foreach ($row as $key=>$field){
$letter->set($key, $field);
}
$section = $PHPWord->createSection ();
if ($count >= 0)
$letterContnt = "{$letter->output()}" . $section->addPageBreak ();
else
$letterContnt = $letter->output();
$html_dom = new simple_html_dom ();
$html_dom->load ( '<html><body>' . $letterContnt . '</body></html>' );
$html_dom_array = $html_dom->find ( 'html', 0 )->children ();
$initial_state = array (
// Required parameters:
'phpword_object' => $PHPWord
); // Must be passed by reference.
htmltodocx_insert_html ( $section, $html_dom_array [0]->nodes, $initial_state );
$count++;
}
if($count==0)
die("No Data Found. Unable to Generate Letter.");
$letterName = preg_replace ( '/\s+/', '', $letterName );
// print_r ();
$fileName = str_replace ( 'LTR', '', $letterName ) . '_' . $affectedIds . '.docx';
$h2d_file_uri = tempnam ( " ", "htd" );
$objWriter = PHPWord_IOFactory::createWriter ( $PHPWord, 'Word2007' );
$objWriter->save ( $h2d_file_uri );
// Download the file:
header ( 'Content-Description: File Transfer' );
header ( 'Content-Type: application/octet-stream' );
header ( 'Content-Disposition: attachment; filename=' . $fileName . '' );
header ( 'Content-Transfer-Encoding: binary' );
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header ( 'Content-Length: ' . filesize ( $h2d_file_uri ) );
ob_clean ();
flush ();
$status = readfile ( $h2d_file_uri );
unlink ( $h2d_file_uri );
exit ();
// Save File
}
1 ответ
Проверьте файл apache error_log, чтобы увидеть, что это за ошибка? Если вы используете xampp, то он должен быть в C:\xampp\apache\logs\error.log