public function init()
 {
     //language translator
     $this->view->pageTitle = $this->view->translate('New Office');
     //session
     $sessionName = new Zend_Session_Namespace('ourbank');
     $this->view->createdby = $sessionName->primaryuserid;
     $this->view->adm = new App_Model_Adm();
     $individualcommon = new Familycommonview_Model_familycommonview();
     $module = $individualcommon->getmodule('Office');
     //module id for delete path
     foreach ($module as $module_id) {
     }
     $this->view->mod_id = $module_id['parent'];
     $this->view->sub_id = $module_id['module_id'];
 }
 public function editcropAction()
 {
     $this->view->title = $this->view->translate('Edit Contact');
     $this->view->title = $this->view->translate('Add Crop');
     //Base line data
     $familycommon = new Familycommonview_Model_familycommonview();
     $this->view->memberid = $this->_getParam('id');
     $this->view->membername = $familycommon->getfamily($this->_getParam('id'));
     //agriculture view
     $this->view->agriculture = $edit_agriculture = $familycommon->getagriculturedetails($this->_getParam('id'));
     $this->view->acretotal = $familycommon->getacretotal($this->_getParam('id'));
     $this->view->guntatotal = $familycommon->getguntatotal($this->_getParam('id'));
     $revvillageid = $this->view->membername[0]['rev_village_id'];
     if ($revvillageid) {
         $revvillagename = $this->view->adm->editRecord("ourbank_master_villagelist", $revvillageid);
     }
     //getting module id and submodule id
     $module = $familycommon->getmodule('Family');
     foreach ($module as $module_id) {
     }
     $this->view->mod_id = $module_id['parent'];
     $this->view->sub_id = $module_id['module_id'];
     $this->view->insurance = $familycommon->getinsurance($this->_getParam('id'));
     //load crop details form with two arguments ...
     $form = new Crop_Form_Crop($this->_getParam('id'), $this->_getParam('subId'));
     $this->view->form = $form;
     $this->view->id = $this->_getParam('id');
     $this->view->submitform = new Crop_Form_Submit();
     //dynamically change the path name
     $addressmodel = new Address_Model_addressInformation();
     $module_name = $addressmodel->getmodule($this->view->subId);
     foreach ($module_name as $module_view) {
         $path1 = $module_view['module_description'] . 'commonview';
     }
     $path1 = $this->view->path1 = strtolower($path1);
     $crop = new Crop_Model_Crop();
     $this->view->cropdetails = $crop->getCrop();
     $this->view->seasondetails = $crop->getSeason();
     $this->view->units = $crop->getUnits();
     //update contact details
     if ($this->_request->getPost('submit')) {
         $formdata = $this->_request->getPost();
         //             echo '<pre>'; print_r($formdata);
         //   if($formdata['enteredacre']>=$formdata['availableacre']){
         //   $this->view->errormsg="<p style='color:red;'>The Entered acres should be less than or equal to ".$formdata['availableacre'];
         //   } else {
         $id = $this->_getParam('id');
         $crop = new Crop_Model_Crop();
         $editCrop = $crop->getCropdetails($id);
         for ($j = 0; $j < count($editCrop); $j++) {
             $this->view->adm->addRecord("ourbank_cropdetails_log", $editCrop[$j]);
         }
         $crop->deletecrop($id);
         $tenant = $this->_getParam('tenant');
         $acer = $this->_getParam('acre');
         $gunta = $this->_getParam('gunta');
         $season = $this->_getParam('season');
         $unit = $this->_getParam('unit');
         $quantity = $this->_getParam('quantity');
         $marketed = $this->_getParam('marketed');
         $price = $this->_getParam('price');
         $realised = $this->_getParam('realised');
         $soldDate = $this->_getParam('date');
         $dateconvert = new App_Model_dateConvertor();
         $i = 0;
         foreach ($this->_getParam('crop_id') as $val) {
             if ($soldDate[$i]) {
                 if ($soldDate[$i] == "00/00/0000" or $soldDate[$i] == NULL) {
                     $date = date("y/m/d H:i:s");
                 } else {
                     $date = $dateconvert->mysqlformat($soldDate[$i]);
                 }
             } else {
                 echo $date = date("y/m/d H:i:s");
             }
             $crop = array('family_id' => $id, 'crop_id' => $val, 'land_id' => $tenant[$i], 'season_id' => $season[$i], 'acre' => $acer[$i], 'gunta' => $gunta[$i], 'unit' => $unit[$i], 'quantity' => $quantity[$i], 'marketed' => $marketed[$i], 'price' => $price[$i], 'realised' => $realised[$i], 'sold_date' => $date);
             $i++;
             $this->view->adm->addRecord("ourbank_cropdetails", $crop);
         }
         $this->_redirect('/familycommonview/index/commonview/id/' . $id);
         //   }
     } else {
         //set the contact details in the contact form...
         $sub_id = $this->_getParam('subId');
         $id = $this->_getParam('id');
         $individualcommon = new Familycommonview_Model_familycommonview();
         $this->view->editCrop = $individualcommon->getcrop($this->_getParam('id'));
     }
 }
 public function editassetAction()
 {
     $this->view->title = $this->view->translate('Edit Livingasset details');
     //Base line data
     $familycommon = new Familycommonview_Model_familycommonview();
     $this->view->memberid = $this->_getParam('id');
     $this->view->membername = $familycommon->getfamily($this->_getParam('id'));
     // // // //         $revvillageid = $this->view->membername[0]['rev_village_id'];
     // // // //         if ($revvillageid) {
     // // // //             $revvillagename = $this->view->adm->editRecord("ourbank_master_villagelist",$revvillageid);
     // // // //             $this->view->revvillagename=$revvillagename[0]['name'];
     // // // //         }
     //getting module id and submodule id
     $module = $familycommon->getmodule('Family');
     foreach ($module as $module_id) {
     }
     $this->view->mod_id = $module_id['parent'];
     $this->view->sub_id = $module_id['module_id'];
     $this->view->insurance = $familycommon->getinsurance($this->_getParam('id'));
     //edit assets
     $this->view->memberid = $member_id = $this->_getParam('id');
     //load form for living assets
     $this->view->submoduleid = $this->_getParam('subId');
     //dynamically change the path name
     //get all type of living assets
     $this->view->liveasset_details = $this->view->adm->viewRecord("ourbank_master_liveassets", "id", "DESC");
     //update contact details
     if ($this->_request->isPost() && $this->_request->getPost('Submit')) {
         $id = $this->_getParam('id');
         $submoduleid = $this->_getParam('subid');
         $asset_db = new Livingassets_Model_livingassets();
         $editAsset = $asset_db->getAssetdetails($id);
         for ($j = 0; $j < count($editAsset); $j++) {
             $this->view->adm->addRecord("ourbank_liveassetdetails_log", $editAsset[$j]);
         }
         $asset_db->deleteasset($id);
         $number = $this->_getParam('number');
         $value = $this->_getParam('value');
         $date = $this->_getParam('date');
         $dateconvert = new App_Model_dateConvertor();
         $i = 0;
         foreach ($this->_getParam('assettype') as $val) {
             if ($date[$i]) {
                 if ($date[$i] == "00/00/0000" or $date[$i] == NULL) {
                     $dates = date("y/m/d H:i:s");
                 } else {
                     $dates = $dateconvert->mysqlformat($date[$i]);
                 }
             } else {
                 $dates = date("y/m/d H:i:s");
             }
             if ($value[$i]) {
                 $values = $value[$i];
             } else {
                 $values = 0;
             }
             $assettype = array('submodule_id' => $submoduleid, 'family_id' => $id, 'liveasset_id' => $val, 'number' => $number[$i], 'date_of_value' => $dates, 'value' => $values);
             $i++;
             $this->view->adm->addRecord("ourbank_liveassetdetails", $assettype);
         }
         $this->_redirect('/familycommonview/index/commonview/id/' . $id);
     } else {
         //set the contact details in the contact form...
         $sub_id = $this->_getParam('subId');
         $id = $this->_getParam('id');
         $individualcommon = new Familycommonview_Model_familycommonview();
         $this->view->editAsset = $individualcommon->getlivingassetsdetails($id);
         //$form->populate($editContact[0]);
     }
 }
 public function taluknameAction()
 {
     $this->_helper->layout->disableLayout();
     $rev_villageid = $this->_request->getParam('rev_village');
     $familycommon = new Familycommonview_Model_familycommonview();
     $talukname = $familycommon->gettalukname($rev_villageid);
     if ($talukname) {
         echo $talukname[0]['name'];
     }
 }
 public function editAction()
 {
     $this->view->pageTitle = $this->view->translate('Basic Infrastructure');
     //Base line data
     $familycommon = new Familycommonview_Model_familycommonview();
     $this->view->memberid = $this->_getParam('id');
     $this->view->membername = $familycommon->getfamily($this->_getParam('id'));
     // // // //         $revvillageid = $this->view->membername[0]['rev_village_id'];
     // // // //         if ($revvillageid) {
     // // // //             $revvillagename = $this->view->adm->editRecord("ourbank_master_villagelist",$revvillageid);
     // // // //             $this->view->revvillagename=$revvillagename[0]['name'];
     // // // //         }
     //getting module id and submodule id
     $module = $familycommon->getmodule('Family');
     foreach ($module as $module_id) {
     }
     $this->view->mod_id = $module_id['parent'];
     $this->view->sub_id = $module_id['module_id'];
     $this->view->insurance = $familycommon->getinsurance($this->_getParam('id'));
     // edit infrastructure
     $this->view->title = $this->view->translate("PRA details");
     $this->view->memberid = $member_id = $this->_getParam('id');
     $infra_model = new Infrastructure_Model_infrastructure();
     $this->view->memberid = $member_id = $this->_getParam('id');
     //view page listing infrastructure  details
     $this->view->housetype = $housetype = $infra_model->housetype();
     $this->view->ownership = $ownership = $infra_model->houseownership();
     $this->view->cookingfuel = $cookingfuel = $infra_model->cookingfuel();
     $this->view->edithousingtype = $infra_model->edithousingtype($member_id);
     $this->view->editownership = $infra_model->editownership($member_id);
     $this->view->editcookfuel = $infra_model->editcookfuel($member_id);
     //update the infrastructure details...
     if ($this->_request->isPost() && $this->_request->getPost('update')) {
         $formData = $this->_request->getPost();
         $house1 = $this->_request->getParam('housetype');
         $owner1 = $this->_request->getParam('ownership');
         $fuel1 = $this->_request->getParam('cookingfuel');
         // //        		$this->view->createdby = $this->view->globalvalue[0]['id'];
         $this->view->memberid = $member_id = $this->_getParam('id');
         //insert main table details to log tables
         $habits = $this->view->adm->getRecord('ourbank_infrastructure', 'member_id', $member_id);
         for ($j = 0; $j < count($habits); $j++) {
             echo '<pre>';
             print_r($habits[$j]);
             $this->view->adm->addRecord("ourbank_infrastructure_log", $habits[$j]);
         }
         // removing the existing record
         $infra_model->deleteinfrastructure($member_id);
         if ($formData) {
             $this->view->adm->addRecord("ourbank_infrastructure", array('id' => '', 'member_id' => $member_id, 'housetype_id' => $house1, 'ownership_id' => $owner1, 'fuel_id' => $fuel1, 'created_date' => date("y/m/d H:i:s")));
         }
         //redirecting page to family view
         $this->_redirect('/familycommonview/index/commonview/id/' . $member_id);
     }
 }
 public function editAction()
 {
     $this->view->title = $this->view->translate("Edit agriculture details");
     //Base line data
     $agriculture = new Agriculture_Model_agriculture();
     $familycommon = new Familycommonview_Model_familycommonview();
     $this->view->memberid = $this->_getParam('id');
     $familycommon = new Familycommonview_Model_familycommonview();
     $this->view->membername = $familycommon->getfamily($this->_getParam('id'));
     $revvillageid = $this->view->membername[0]['rev_village_id'];
     $this->view->membername = $familycommon->getfamily($this->_getParam('id'));
     //$this->view->owner = $agriculture->owner($this->_getParam('id'));
     $this->view->owner = $agriculture->owner1();
     $this->view->village = $agriculture->village($this->_getParam('id'));
     $this->view->acquistion = $acquistion = $agriculture->ownershiptypes();
     if ($revvillageid) {
         $revvillagename = $this->view->adm->editRecord("ourbank_master_villagelist", $revvillageid);
     }
     //getting module id and submodule id
     $module = $familycommon->getmodule('Family');
     foreach ($module as $module_id) {
     }
     $this->view->mod_id = $module_id['parent'];
     $this->view->sub_id = $module_id['module_id'];
     $this->view->insurance = $familycommon->getinsurance($this->_getParam('id'));
     //edit agriculture
     $this->view->memberid = $member_id = $this->_getParam('id');
     //count number of family members
     $family_model = new Agriculture_Model_agriculture();
     $this->view->land_details = $count_member = $family_model->edit_landtypes();
     $this->view->family_number = $number = count($count_member);
     //load form with respective to number of family member
     $addForm = new Agriculture_Form_agriculture($number);
     $this->view->form = $addForm;
     $owner = $this->view->adm->viewRecord("ourbank_master_ownershiptype", "id", "ASC");
     $this->view->ownertype = $owner;
     $this->view->agriculture = $family_model->getagriculturedetails($member_id);
     if ($this->_request->getPost('submit')) {
         $id = $this->_getParam('id');
         $editagri = $family_model->getlog_details($id);
         for ($j = 0; $j < count($editagri); $j++) {
             $this->view->adm->addRecord("ourbank_agriculture_log", $editagri[$j]);
         }
         $family_model->deleteagri($id);
         $land_id = $this->_request->getParam('tenant');
         $acquistion = $this->_request->getParam('acquistion');
         $village_id = $this->_request->getParam('villagename');
         $ownername = $this->_request->getParam('ownername');
         $survey_no = $this->_request->getParam('survey');
         $acre = $this->_request->getParam('acre');
         $gunta = $this->_request->getParam('gunta');
         $value = $this->_request->getParam('acrevalue');
         $i = 0;
         foreach ($this->_getParam('tenant') as $val) {
             $agri = array('id' => '', 'family_id' => $member_id, 'landowner_name' => $ownername[$i], 'acquistion_id' => $acquistion[$i], 'land_id' => $land_id[$i], 'villagename' => $village_id[$i], 'survey_no' => $survey_no[$i], 'gunta' => $gunta[$i], 'acre' => $acre[$i]);
             $i++;
             $this->view->adm->addRecord("ourbank_agriculture", $agri);
         }
         $this->_redirect('/familycommonview/index/commonview/id/' . $id);
     }
 }
 public function commonviewAction()
 {
     // //         //Acl
     // //         //$access = new App_Model_Access();
     // //         //$checkaccess = $access->accessRights('Individual',$this->view->globalvalue[0]['name'],'commonviewAction');
     // //         //if (($checkaccess != NULL)) {
     $id = $this->_request->getParam('id');
     $this->view->memberid = $id;
     $familycommon = new Familycommonview_Model_familycommonview();
     $member_name = $familycommon->getfamily($id);
     $villageid = $member_name[0]['rev_village_id'];
     $parentid = $member_name[0]['parentoffice_id'];
     $talukname = $familycommon->gettalukname($villageid);
     if ($talukname) {
         $this->view->villagename = $talukname[0]['name'];
     }
     $kootaname = $familycommon->getkoota($parentid);
     if ($kootaname) {
         $this->view->kootaname = $kootaname[0]['name'];
     }
     //getting module id and submodule id
     $module = $familycommon->getmodule('Family');
     $this->view->mod_id = $module[0]['parent'];
     $this->view->sub_id = $module[0]['module_id'];
     $officemodule = $familycommon->getmodule('Office');
     //print_r($officemodule);
     $officesub_id = $officemodule[0]['module_id'];
     $pincode1 = $familycommon->getpincode($officesub_id, $villageid);
     if ($pincode1) {
         $this->view->pincode1 = $pincode1[0]['zipcode'];
     }
     $this->view->insurance = $familycommon->getinsurance($id);
     //         //geting family details, family details, health, economic, education details
     $this->view->membername = $member_name;
     // //      $this->view->family =$familycommon->getfamilydetails($id);
     $this->view->agriculture = $edit_agriculture = $familycommon->getagriculturedetails($id);
     $this->view->acretotal = $familycommon->getacretotal($id);
     $this->view->guntatotal = $familycommon->getguntatotal($id);
     $this->view->family = $familycommon->getfamilydetails($id);
     // //        $this->view->getentitlement=$familycommon->getentitlement();
     $this->view->crop = $familycommon->getcrop($id);
     $this->view->loandetails = $familycommon->getloandetails($id);
     $this->view->savingsdetails = $familycommon->getsavingsdetails($id);
     $this->view->gethabithealth = $familycommon->gethabithealth($id);
     $this->view->gethabitchallenge = $familycommon->gethabitphychallenge($id);
     $this->view->getchronicdisease = $familycommon->getchronicdisease($id);
     $this->view->getfamilymembers = $familycommon->getfamilyname($id);
     $this->view->livingassets = $familycommon->getlivingassetsdetails($id);
     $this->view->nonlivingassets = $familycommon->getnonlivingassetsdetails($id);
     // 	//PRA Based Services
     $this->view->praservice = $familycommon->praservice($id);
     $this->view->expense = $familycommon->getexpense($id);
     // 	// Basic Infrastructure
     $this->view->housingtype = $familycommon->housingtype($id);
     $this->view->ownership = $familycommon->ownership($id);
     $this->view->cookfuel = $familycommon->cookfuel($id);
     // 	//Annual income details
     $this->view->incomedetails = $familycommon->getincomedetails($id);
     $this->view->incometotal = $familycommon->getincometotal($id);
     // /*
     // // 	$this->view->loandtotal=$individualcommon->getloantotal($id);
     // //         $this->view->servicedetails=$individualcommon->servicedetails($id);
     // //         $this->view->family =$individualcommon->getfamilydetails($id);
     // //        $this->view->activities=$individualcommon->getactivities($id);
     //         //}
     //         //else {
     //         //$this->_redirect('index/index');
     //         //}*/
 }
 public function editAction()
 {
     $this->view->title = $this->view->translate("Edit expense information");
     //Base line data
     $familycommon = new Familycommonview_Model_familycommonview();
     $this->view->memberid = $this->_getParam('id');
     $this->view->membername = $familycommon->getfamily($this->_getParam('id'));
     // // // //         $revvillageid = $this->view->membername[0]['rev_village_id'];
     // // // //         if ($revvillageid) {
     // // // //             $revvillagename = $this->view->adm->editRecord("ourbank_master_villagelist",$revvillageid);
     // // // //             $this->view->revvillagename=$revvillagename[0]['name'];
     // // // //         }
     //getting module id and submodule id
     $module = $familycommon->getmodule('Family');
     foreach ($module as $module_id) {
     }
     $this->view->mod_id = $module_id['parent'];
     $this->view->sub_id = $module_id['module_id'];
     $this->view->insurance = $familycommon->getinsurance($this->_getParam('id'));
     // edit expences
     $this->view->memberid = $member_id = $this->_getParam('id');
     $this->view->submoduleid = $submoduleid = $this->_getParam('subId');
     //count number of family members
     $db_model = new Expense_Model_expense();
     $this->view->expense_details = $count_expense = $db_model->getexpensetypes();
     $this->view->number = $number = count($count_expense);
     // //load form with respective to number of family member
     $addForm = new Expense_Form_expense($number);
     $this->view->form = $addForm;
     //set the value of member name and sex
     for ($i = 1; $i <= $number; $i++) {
         foreach ($count_expense as $count_expense1) {
             $b = 'source_id' . $i;
             $addForm->{$b}->setValue($count_expense1['id']);
             $i++;
         }
     }
     // // //set the value of expense...
     $expensedetails = $db_model->get_expensedetails($member_id);
     $i = 1;
     foreach ($expensedetails as $expensedetails1) {
         $c = 'value' . $expensedetails1['expense_id'];
         //         $d='source_id'.$i;
         $addForm->{$c}->setValue($expensedetails1['value']);
         //         $addForm->$d->setValue($expensedetails1['expense_id']);
         $i++;
     }
     // //update the family health details...
     if ($this->_request->isPost() && $this->_request->getPost('update')) {
         $submoduleid = $this->_getParam('subId');
         $formData = $this->_request->getPost();
         if ($addForm->isValid($formData)) {
             $expense_db = new Expense_Model_expense();
             $editExpense = $expense_db->get_expensedetails($member_id);
             for ($j = 0; $j < count($editExpense); $j++) {
                 $this->view->adm->addRecord("ourbank_expensedetails_log", $editExpense[$j]);
             }
             $expense_db->deleteexpense($member_id);
             for ($i = 1; $i <= $number; $i++) {
                 if ($this->_request->getParam('value' . $i)) {
                     $this->view->adm->addRecord("ourbank_expensedetails", array('id' => '', 'submodule_id' => $submoduleid, 'family_id' => $member_id, 'expense_id' => $this->_request->getParam('source_id' . $i), 'value' => $this->_request->getParam('value' . $i), 'created_date' => date("y/m/d H:i:s"), 'created_by' => $this->view->createdby));
                 }
             }
             $this->_redirect('/familycommonview/index/commonview/id/' . $member_id);
         }
     }
 }