i am trying to generate a set of reports using the doccy extension,
in view:
echo CHtml::checkBoxList('letter', '', array('pletter'=>'Letter To Parents','out'=>'Out of Class Letter'), array('multiple'=>true), array('separator'=>''));
in the controller:
if(isset($_POST['Assignment'])){
$model->attributes=$_POST['Assignment'];
if($model->save()){$this->redirect(array('view','id'=>$model->id));}
if($_POST['letter']){
foreach ($_POST['letter'] as $letters){
if($letters == 'out'){
$this->actionOutOfClass($model->studentID, $model->periodID, $model->behavGroupID, $model->assignDate);
}
if($letters == 'pletter'){
$this->actionLetter($model->studentID, $model->category, $model->behavGroupID, $model->ActionID, $model->assignDate);
}
}
}
}
$this->render('newupdate',array('model'=>$model,));
public function actionLetter($studentID, $category, $behavior, $action, $startDate)
{
$catName = Category::model()->find('color = \'' . $category . '\'')->name;
$actionName = Action::model()->find('ID = \'' . $action . '\'')->E_Name;
$behavior = Behaviorgroup::model()->find('ID = \'' . $behavior . '\'')->A_BGName;
$studentInfo = Student::model()->find('Student_Number = \'' . $studentID . '\'');
$StudentName = $studentInfo->E_Child_Name . " " . $studentInfo->F_Father_Name . " " . $studentInfo->E_Family_Name;
$num = 2;
$date = date("Y-m-d");
$this->doccy->newFile('Templates/Letter_Template.docx'); // template.docx must be located in protected/views/report/template.docx where "report" is the name of the controller from which is renderDocx called (alternatively you must configure option "templatePath")
$this->doccy->phpdocx->assign("#TITLE1#","$num"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#Date#","$date"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#StudentName#","$StudentName"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#Degree#","$catName"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#Behavior#","$behavior"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#Action#","$actionName"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#startDate#","$startDate"); // this would replicate two members block with the associated values
$this->renderDocx("Letter.docx", true); // use $forceDownload=false in order to (just) store file in the outputPath folder.
}
public function actionOutOfClass($studentID, $period, $behavior, $startDate)
{
$behavior = Behaviorgroup::model()->find('ID = \'' . $behavior . '\'')->A_BGName;
$matiere = Matiere::model()->find('Subject_Code = \'' . $period . '\'')->E_Subject_Name;
$studentInfo = Student::model()->find('Student_Number = \'' . $studentID . '\'');
$StudentName = $studentInfo->E_Child_Name . " " . $studentInfo->F_Father_Name . " " . $studentInfo->E_Family_Name;
$num = 2;
$date = date("Y-m-d");
$this->doccy->newFile('Templates/Out_Of_Class_Template.docx'); // template.docx must be located in protected/views/report/template.docx where "report" is the name of the controller from which is renderDocx called (alternatively you must configure option "templatePath")
$this->doccy->phpdocx->assign("#TITLE1#","$num"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#Date#","$date"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#StudentName#","$StudentName"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#Degree#","$matiere"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#Behavior#","$behavior"); // this would replicate two members block with the associated values
$this->doccy->phpdocx->assign("#startDate#","$startDate"); // this would replicate two members block with the associated values
$this->renderDocx("OutOfClass.docx", true); // use $forceDownload=false in order to (just) store file in the outputPath folder.
}
but i have a problem with the render. in the same action there is 3 render
render to view and the renderdocx in the letter action and out of class action
how to fix this
i need to generate 1 or 2 reports and then render to the view page and this is impossible with this code
it either redirect me to the view page, or generate the report (if i select the 2 reports in the view page via the checkbox, it generate one report and not the both two)
can anybody help me?
thank you4463