public function actionAdmin() { $model = new Donor('search'); $model->unsetAttributes(); if (isset($_GET['Donor'])) { $model->setAttributes($_GET['Donor']); } $this->render('admin', array('model' => $model)); }
public function validate($emailInput, $passwordInput) { $dFlag = false; $eFlag = false; $key = 'UyTHkbxiGCt2W4HzmtL0TRKMynDGEqYX'; $email = $this->security->xss_clean($emailInput); $password = $this->security->xss_clean($passwordInput); #set where methods $this->db->where('email', $email); $query1 = $this->db->get('donor'); if ($query1->num_rows == 1) { $depass = $query1->result()[0]->password; if ($password == $this->encrypt->decode($depass, $key)) { $dFlag = true; } } $this->db->where('email', $email); $query2 = $this->db->get('employee'); if ($query2->num_rows == 1) { $depass = $query2->result()[0]->password; if ($password == $this->encrypt->decode($depass, $key)) { $eFlag = true; } } if ($dFlag) { $row = $query1->row(); $donor = new Donor($row); $data = array('user_Mode' => 'd', 'dId' => $donor->getDId(), 'lname' => $donor->getLname(), 'photo' => $donor->getPhoto(), 'validated' => true); $this->session->set_userdata($data); return true; } else { if ($eFlag) { $row = $query2->row(); $employee = new Employee($row); $data = array('user_Mode' => $employee->getType(), 'eId' => $employee->getEId(), 'lname' => $employee->getLname(), 'photo' => $employee->getPhoto(), 'validated' => true); $this->session->set_userdata($data); return true; } } return false; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Donor::find($id)->delete(); Session::flash('success', 'Successfully deleted donor!'); return Redirect::back(); }
public function getDonorDetails() { $donors = Donor::get(); $result = View::make('reports.donorslist', ['donors' => $donors]); return $result; }
<?php $this->breadcrumbs = array(Donor::label(2), Yii::t('app', 'Index')); $this->menu = array(array('label' => Yii::t('app', 'Create') . ' ' . Donor::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Manage') . ' ' . Donor::label(2), 'url' => array('admin'))); ?> <h1><?php echo GxHtml::encode(Donor::label(2)); ?> </h1> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the primary key value. Defaults to null, meaning using the 'id' GET variable */ public function loadDonor($id = null) { if ($this->_model === null) { if ($id !== null || isset($_GET['id'])) { $this->_model = Donor::model()->findbyPk($id !== null ? $id : $_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
<div class="row"> <?php echo $form->label($model, 'program_id'); ?> <?php echo $form->dropDownList($model, 'program_id', GxHtml::listDataEx(Program::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'donor_id'); ?> <?php echo $form->dropDownList($model, 'donor_id', GxHtml::listDataEx(Donor::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'online'); ?> <?php echo $form->textField($model, 'online'); ?> </div> <div class="row"> <?php echo $form->label($model, 'title_ar');
<?php echo $form->labelEx($model, 'program_id'); ?> <?php echo $form->dropDownList($model, 'program_id', GxHtml::listDataEx(Program::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'program_id'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'donor_id'); ?> <?php echo $form->dropDownList($model, 'donor_id', GxHtml::listDataEx(Donor::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'donor_id'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'online'); ?> <?php echo $form->textField($model, 'online'); ?> <?php echo $form->error($model, 'online'); ?>
public function getCount() { $count = Donor::all()->count(); return Response::json(array('status' => true, 'count' => rand(0, 50))); }
<?php $this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', 'Manage')); $this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('distribution-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1><?php echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2)); ?> </h1> <p> You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); ?> <div class="search-form"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'distribution-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'name', array('name' => 'program_id', 'value' => 'GxHtml::valueEx($data->program)', 'filter' => GxHtml::listDataEx(Program::model()->findAllAttributes(null, true))), array('name' => 'donor_id', 'value' => 'GxHtml::valueEx($data->donor)', 'filter' => GxHtml::listDataEx(Donor::model()->findAllAttributes(null, true))), 'online', 'title_ar', array('class' => 'CButtonColumn'))));
/** * Add or edit donor * CODE: donor_create */ public function executeUpdate(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } if ($request->getParameter('id')) { $donor = DonorPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($donor); $this->title = 'Edit donor'; $success = 'Donor information has been successfully changed!'; } else { $donor = new Donor(); $this->title = 'Add new donor'; $success = 'Donor information has been successfully created!'; } $this->back = $request->getReferer(); $this->form = new DonorForm($donor); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('donor')); if ($this->form->isValid()) { $donor->setCoDonorId($this->form->getValue('co_donor_id')); if ($this->form->getValue('affiliation_id') == 0) { $donor->setAffiliationId(null); } else { $donor->setAffiliationId($this->form->getValue('affiliation_id')); } if ($this->form->getValue('block_mailings') == null) { $donor->setBlockMailings(0); } else { $donor->setBlockMailings($this->form->getValue('block_mailings')); } $donor->setProspectComment($this->form->getValue('prospect_comment')); $donor->setSalutation($this->form->getValue('salutation')); if ($this->form->getValue('company_id') == 0) { $donor->setCompanyId(null); } else { $donor->setCompanyId($this->form->getValue('company_id')); } $donor->setPosition($this->form->getValue('position')); $donor->setDonorPotential($this->form->getValue('donor_potential')); if ($this->form->getValue('person_id') == 0) { $donor->setPersonId(null); } else { $donor->setPersonId($this->form->getValue('person_id')); } if ($this->form->isNew()) { $donor->setDateAdded(date()); } $donor->setDateUpdated(date()); $donor->save(); $this->getUser()->setFlash('success', $success); $last = $request->getParameter('back'); if (strstr($last, 'donation/create')) { $back_url = $last; } else { $back_url = 'donor'; } $this->redirect($back_url); } else { $this->getUser()->setFlash('success', 'Please select Person, Company or Affiliation!'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@donor'; } $this->donor = $donor; }
echo $credit_label; ?> </th> <th><?php echo $actions_label; ?> </th> </tr> </thead> <tbody> <?php $debit = 0.0; $credit = 0.0; $customers = CHtml::encodeArray(CHtml::listData(Customer::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId'), 'select' => 'id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name')); $customers[0] = ''; $donors = CHtml::encodeArray(CHtml::listData(Donor::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId'), 'select' => 'id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name')); $donors[0] = ''; $accounts = CHtml::encodeArray(CHtml::listData(Account::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId'), 'select' => 'id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name')); foreach ($models as $n => $transrow) { ?> <tr class="<?php echo $n % 2 ? 'even' : 'odd'; ?> "> <td> <?php echo CHtml::activeDropDownList($transrow, "[{$n}]accountId", $accounts, array('style' => 'width:' . 120 * Yii::app()->user->getState('TransactionEditWidthMultiplier') . 'px')) . "<br>" . CHtml::activeDropDownList($transrow, "[{$n}]customerId", $customers, array('style' => 'width:' . 120 * Yii::app()->user->getState('TransactionEditWidthMultiplier') . 'px')) . "<br>" . CHtml::activeDropDownList($transrow, "[{$n}]donorId", $donors, array('style' => 'width:' . 120 * Yii::app()->user->getState('TransactionEditWidthMultiplier') . 'px')); ?> <td>
public function delete_destroy($object_id = false) { $donor = Donor::find($object_id); $donor->delete(); return Redirect::to_action('donors@index'); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Donor $value A Donor object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Donor $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Declares an association between this object and a Donor object. * * @param Donor $v * @return Donation The current object (for fluent API support) * @throws PropelException */ public function setDonor(Donor $v = null) { if ($v === null) { $this->setDonorId(NULL); } else { $this->setDonorId($v->getId()); } $this->aDonor = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Donor object, it will not be re-added. if ($v !== null) { $v->addDonation($this); } return $this; }
/** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); DB::table('donors')->truncate(); $donor = new Donor(); $donor->name = "Lorem Ipsum"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 1; $donor->gender = 1; $donor->save(); $donor = new Donor(); $donor->name = "Dolar Sit"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 2; $donor->gender = 2; $donor->save(); $donor = new Donor(); $donor->name = "Amet Lo"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 1; $donor->gender = 1; $donor->save(); $donor = new Donor(); $donor->name = "Consectetur"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 4; $donor->gender = 2; $donor->save(); $donor = new Donor(); $donor->name = "Voluptatem"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 6; $donor->gender = 2; $donor->save(); $donor = new Donor(); $donor->name = "Lorem Ipsum"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 1; $donor->gender = 1; $donor->save(); $donor = new Donor(); $donor->name = "Dolar Sit"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 2; $donor->gender = 2; $donor->save(); $donor = new Donor(); $donor->name = "Amet Lo"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 1; $donor->gender = 1; $donor->save(); $donor = new Donor(); $donor->name = "Consectetur"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 4; $donor->gender = 2; $donor->save(); $donor = new Donor(); $donor->name = "Voluptatem"; $donor->dob = '1980-10-10'; $donor->blood_group_id = 6; $donor->gender = 2; $donor->save(); }
public function getDonorDetails() { $donors = Donor::get(); $result = View::make('reports.donorslist', ['donors' => $donors]); return PDF::load($result, 'A4', 'portrait')->download(); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $rules = array('category' => 'required|Integer', 'condition' => 'required|Integer', 'name' => 'required', 'description' => 'required', 'donor' => 'required|Integer', 'orignal_price' => 'required|Numeric', 'price' => 'required|Numeric', 'image' => 'required', 'attributes' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return $this->response(array('statusCode' => 400, 'statusDescription' => 'Bad Request', 'errors' => $validator->messages()->toJson())); } else { $iGetInstitute = Donor::where('user_id', Input::get('donor'))->first(); $product = Product::find($id)->update(array('products_price' => Input::get('price'), 'products_orginal_price' => Input::get('orignal_price'), 'brand' => Input::get('brand', NULL), 'products_status' => Input::get('products_status', 1), 'products_donar' => Input::get('donor'), 'condition' => Input::get('condition'), 'products_image' => Input::get('image'), 'gender' => Input::get('gender'), 'age_range' => Input::get('age_range'), 'collections_id' => Input::get('collections_id'), 'seasons_id' => Input::get('seasons_id'), 'types_id' => Input::get('types_id'), 'freshly_faved' => Input::get('freshly_faved'), 'institution_id' => $iGetInstitute->institution_id)); // $product->save(); $category = Categories::find(Input::get('category')); $product = Product::find($id); //$product->productCategory()->save($category); Product::find($id)->productCategory()->detach(); //updateExistingPivot($category->categories_id, array("categories_id"=>$category->categories_id),false); $product->productCategory()->save($category); if (Input::has('tags')) { Product::find($id)->productTags()->detach(); $product = Product::find($id); $inptags = Input::get("tags"); $tags = explode(",", $inptags); foreach ($tags as $key => $value) { $ctag = Tags::find($value); if ($ctag) { $product->productTags()->save($ctag); } } } $attributes = json_decode(Input::get("attributes"), TRUE); //$attribs = array(); ProductsAttributes::where("products_id", $id)->delete(); foreach ($attributes as $key => $value) { $opt_values = explode(",", $value); foreach ($opt_values as $optval) { //echo $key." ".$optval."<br/>"; $attribute = new ProductsAttributes(array('options_id' => $key, 'options_values_id' => $optval)); $product->productsAttributes()->save($attribute); } } $description = ProductsDescription::find($id)->update(array("products_name" => Input::get("name"), "products_description" => Input::get("description"))); //$product->productsDescription()->save($description); return $this->response(array('statusCode' => 100, 'statusDescription' => 'Success')); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { /*$validator = $this->validate(); if($validator->fails()){ return Redirect::back() ->withErrors($validator->messages()) ->withInput(Input::all()); }*/ $validator = $this->validate(); if ($validator->fails()) { if (Request::ajax()) { return Response::json(array('success' => false, 'messages' => $validator->messages())); } else { return Redirect::back()->withErrors($validator->messages())->withInput(Input::all()); } } $donor = Donor::find(Input::get('donor_id')); $product = Product::find(Input::get('product_id')); // Donor can only give blood of it's own blood type if (strtolower($product->category->name) == 'blood') { if (strtolower($donor->blood_group->name) != strtolower($product->name)) { //apply ajax if (Request::ajax()) { return Response::json(array('success' => false, 'messages' => ['This donor is only able to donate blood of type ' . $donor->blood_group->name . ' only.'])); } else { return Redirect::back()->withErrors(['This donor is only able to donate blood of type ' . $donor->blood_group->name . ' only.'])->withInput(Input::all()); } } } // Check if donor is eligible to make the donation if (count($donor->donations)) { // Check if donor is donating within the validity period $validity_days = $product->validity_period; $last_donated_at = new Carbon\Carbon($donor->donations->last()->donated_at); $next_possible_donation_date = $last_donated_at->addDays($validity_days); $today = Carbon\Carbon::now(); if ($next_possible_donation_date->gt($today)) { //if ajax request nam return response. if (Request::ajax()) { return Response::json(array('success' => false, 'messages' => ['This donor is not able to donate untill ' . $next_possible_donation_date->format('Y-m-d') . '.'])); } else { return Redirect::back()->withErrors(['This donor is not able to donate untill ' . $next_possible_donation_date->format('Y-m-d') . '.'])->withInput(Input::all()); } } } DB::beginTransaction(); $donation = new Donation(); $donation->donor_id = Input::get('donor_id'); $donation->product_id = Input::get('product_id'); $donation->location_id = Input::get('location_id'); $donation->quantity = Input::get('quantity'); $donation->donated_at = Input::get('donated_at'); $donation->save(); /*if (Request::ajax()){ return Response::json(array( 'success' => true, 'donors' => [''] + Donor::all()->lists('name_with_blood_group', 'id'), 'donor_id' => $donor->id, )); }*/ // Increment product quantity /*$product = $donation->product; $product->quantity = $product->quantity + $donation->quantity; $product->save();*/ // increment count in item_in table // increment count in location_products table $response = Event::fire('donation.create', array($donation)); DB::commit(); if (Request::ajax()) { return Response::json(array('success' => true, 'donors' => [''] + Donor::all()->lists('name_with_blood_group', 'id'), 'donor_id' => $donor->id)); } else { Session::flash('success', 'Successfully created donation!'); return Redirect::route('donation.index'); } }