function editworkAction() { if ($this->isLoggedIn() == 0) { $this->_redirect('/admin/index'); } $this->view->langId = $this->_request->getParam('langId'); $this->view->workId = $this->_request->getParam('workId'); $fitnessWorkouts = new FitnessWorkouts(); $fitnessWorkoutsMulti = new FitnessWorkoutsMultilang(); $fitnessExercises = new FitnessExerciseGeneral(); $fitnessExercisesMulti = new FitnessExerciseGeneralMultilang(); $fitnessTimeframes = new FitnessWorkoutTimeframes(); $workoutDocuments = new FitnessExerciseDocuments(); $workoutDocumentsMulti = new FitnessExerciseDocumentsMultilang(); $fitnessDevices = new AppleDevices(); $fitnessKeys = new FitnessAndroidKey(); $adminData = new FitnessAdminAccounts(); $sess = new Zend_Session_Namespace('AdminSession'); $adminType = $adminData->getTypeByUsername($sess->username); $this->view->adminType = $adminType['admin_user_type']; $listExercises = $fitnessExercises->selectRecordsWorkout(); $exerciseArray = array(); $i = 0; foreach ($listExercises as $exercise) { $exerciseArray[$i]["exercise_id"] = $exercise['workout_id']; $exerciseNameArray = $fitnessExercisesMulti->getWorkoutName($exercise['workout_id'], $this->getDefaultLanguage()); $exerciseArray[$i]["exercise_name"] = $exerciseNameArray['workout_name']; $i = $i + 1; } $exerciseArray = $this->array_sort_by_column($exerciseArray, 'exercise_name'); $this->view->listExercises = $exerciseArray; $this->view->listtimeframes = $fitnessTimeframes->listTimeframes(); $this->view->workData = $fitnessWorkouts->getWorkout($this->_request->getParam('workId')); $exerciseArray = explode(",", $this->view->workData['work_exercises']); $this->view->exercises = $exerciseArray; //$this->view->workoutDocuments = $workoutDocumentsData; //$this->view->workoutDocumentsMulti = $workoutDocumentsMultiData; if ($this->_request->getParam('langId') != "") { $workmultiData = $fitnessWorkoutsMulti->getWorks($this->_request->getParam('workId'), $this->_request->getParam('langId')); if ($this->_request->getParam('langId') == 1) { $this->view->workmultiDataTranslate = $fitnessWorkoutsMulti->getWorks($this->_request->getParam('workId'), 2); } $this->view->workmulti = $workmultiData; $this->view->workname = $workmultiData['work_name']; } else { $workmultiData = $fitnessWorkoutsMulti->getWorks($this->_request->getParam('workId'), $this->getDefaultLanguage()); $this->view->workmulti = $workmultiData; $this->view->workname = $this->view->workData['work_name']; } $this->view->exercises = explode(",", $this->view->workData['work_exercises']); $d = 0; foreach ($this->view->exercises as $exerciseID) { $exerciseDetails = $fitnessExercisesMulti->getWorkoutName($exerciseID, $this->getDefaultLanguage()); $sortExerciseArray[$d]['name'] = $exerciseDetails['workout_name']; $sortExerciseArray[$d]['id'] = $exerciseID; $d = $d + 1; } if ($this->view->workData['work_exercises_order'] != "") { $this->view->sortcomplete = explode(",", $this->view->workData['work_exercises_order']); $sortDiff = array_diff($this->view->exercises, $this->view->sortcomplete); $reversesortDiff = array_diff($this->view->sortcomplete, $this->view->exercises); //print_r($this->view->exercises);echo "<br/>"; //print_r($this->view->sortcomplete);echo "<br/>"; //remove deleted exercises foreach ($this->view->sortcomplete as $key => $exerciseID) { if (in_array($exerciseID, $reversesortDiff)) { unset($this->view->sortcomplete[$key]); } } $j = 0; foreach ($this->view->sortcomplete as $exerciseID) { $exerciseDetails = $fitnessExercisesMulti->getWorkoutName($exerciseID, $this->getDefaultLanguage()); $sortCompleteExerciseArray[$j]['name'] = $exerciseDetails['workout_name']; $sortCompleteExerciseArray[$j]['id'] = $exerciseID; $j = $j + 1; } } $r = 0; foreach ($sortDiff as $diff) { $exerciseDiffDetails = $fitnessExercisesMulti->getWorkoutName($diff, $this->getDefaultLanguage()); $sortDiffExerciseArray[$r]['name'] = $exerciseDiffDetails['workout_name']; $sortDiffExerciseArray[$r]['id'] = $diff; $r = $r + 1; } $this->view->sortExercises = $sortExerciseArray; $this->view->sortCompleteExercises = $sortCompleteExerciseArray; $this->view->sortDiffExercises = $sortDiffExerciseArray; $workArray = array(); $workMultiArray = array(); if ($this->_request->isPost()) { $workId = $this->_request->getPost('work_id'); if ($this->_request->getPost('langId') == "") { //$workImage = $_FILES["work_image"]["name"]; $workArray['work_name'] = $this->_request->getPost('work_name'); $workArray['work_image_list'] = $this->_request->getPost('work_image'); $workArray['work_exercises'] = rtrim($this->_request->getPost("exerciseslist", ",")); $workArray['work_duration'] = $this->_request->getPost('work_duration'); $workArray['work_recovery_time'] = $this->_request->getPost('work_recovery_time'); $workArray['work_recovery_interval'] = $this->_request->getPost('work_recovery_interval'); $workArray['work_filter'] = rtrim($this->_request->getPost("filterlist"), ","); $workArray['description_small'] = $this->_request->getPost("description_small"); $workArray['description_big'] = $this->_request->getPost("description_big"); $workArray['work_level'] = $this->_request->getPost('work_level'); if ($this->_request->getPost('activestatus') != "") { $workArray['isactive'] = $this->_request->getPost('activestatus'); } if ($this->_request->getPost('isfree') != "") { $workArray['status'] = $this->_request->getPost('isfree'); } $where = "id='" . $workId . "'"; $fitnessWorkouts->update($workArray, $where); /*if($workImage!="") { move_uploaded_file($_FILES['work_image']['tmp_name'],'./public/images/exercises/'.$workImage); $this->createThumb('./public/images/exercises/'.$workImage,'./public/images/exercises/thumbs/'.$workImage,100); $this->createThumbMobile('./public/images/exercises/'.$workImage,'./public/images/exercises/thumbs/mobile/'.$workImage,100); }*/ if ($this->_request->getPost('isactive') == 1) { //update the workout change table $fitnessUpdateChange = new FitnessWorkoutChanges(); $changeArray = array(); //check if record exists for today's date $currentDate = date('Y-m-d'); $checkRecord = $fitnessUpdateChange->getRecordByDate($currentDate); if ($checkRecord['count'] < 1) { $changeArray['status'] = 1; $changeArray['change_date'] = $currentDate; $fitnessUpdateChange->addData($changeArray); } /*$devices = $fitnessDevices->getAllDevices(); $keys = $fitnessKeys->getAllKeys(); $message = "The workout ".$this->_request->getPost('work_name')." has been updated in Fitness4.me"; foreach($devices as $device) { if($device['devicetoken'] !="") { //$this->sendNotification('lekha',$message,$device['devicetoken'],4); } } foreach($keys as $key) { if($key['android_key'] !="") { //$this->sentandroid($key['android_key'],$message,4); } }*/ } } if ($this->_request->getPost('langId') != "") { $checkRecords = $fitnessWorkoutsMulti->getLangRecord($this->_request->getPost('work_id'), $this->_request->getPost('langId')); $workMultiArray['work_id'] = $workId; $workMultiArray['lang_id'] = $this->_request->getPost('langId'); $workMultiArray['work_name'] = $this->_request->getPost('work_name'); $workMultiArray['description_small'] = $this->_request->getPost("description_small"); $workMultiArray['description_big'] = $this->_request->getPost("description_big"); if ($checkRecords['count'] > 0) { $fitnessWorkoutsMulti->update($workMultiArray, array('work_id = ?' => $this->_request->getPost('work_id'), 'lang_id = ?' => $this->_request->getPost('langId'))); } else { $fitnessWorkoutsMulti->addData($workMultiArray); } } $this->_redirect('/admin/listworks'); } }
/** * function that handles the paypal payment method * @params amount, userid,workout id * @author lekha * @date 3/22/2012 * */ public function paymentpaypalAction() { $this->view->loginStatus = $this->isLoggedIn(); //if($this->view->loginStatus == 1) //$this->view->memberStatus = $this->checkUserMembership(); if ($this->isLoggedIn() == 0) { $this->_redirect('/index/login'); } $fitnessUser = new FitnessUserGeneral(); $fitnessWorkout = new FitnessWorkouts(); $fitnessworkoutRate = new FitnessWorkoutRates(); $fitnessPromotion = new FitnessPromotionCodes(); $promotionUsers = new FitnessPromotionUsers(); $fitnessUserSettings = new FitnessUserSettings(); $sess = new Zend_Session_Namespace('UserSession'); $userDetails = $fitnessUser->getUserbyUsername($sess->username); $workout_id = $this->_request->getParam('workout_id'); $purchaseType = $this->_request->getParam('type'); //get workout rate $workoutDetails = $fitnessWorkout->getWorkout($workout_id); $workoutrate = $fitnessworkoutRate->getRateByVersion(1); $userSettings = $fitnessUserSettings->getUserSettings($userDetails['user_id']); if ($userSettings['address_check'] != 1) { $this->_redirect('user/settings/details/1'); } $this->view->loginStatus = $this->isLoggedIn(); $this->view->siteurl = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $this->view->baseUrl(); $this->view->user_id = $userDetails['user_id']; $this->view->workout_id = $workout_id; $this->view->purchaseType = $purchaseType; if ($this->_request->getPost('promotion_code') != "") { //check if user has used this promotion code //check if promotion code is active $checkStatus = $fitnessPromotion->checkStatus($this->_request->getPost('promotion_code')); if ($checkStatus['status'] == 1) { $checkUser = $promotionUsers->checkUser($userDetails['user_id'], $this->_request->getPost('promotion_code')); if ($checkUser['count'] < 1) { //get the reduction in price for this promotion $promoDetails = $fitnessPromotion->getpromoByCode($this->_request->getPost('promotion_code')); //insert user in promo table $promouserArray = array(); $promouserArray['promotion_id'] = $promoDetails['id']; $promouserArray['promotion_code'] = $promoDetails['promotion_code']; $promouserArray['user_id'] = $userDetails['user_id']; $promotionUsers->addData($promouserArray); $this->view->reduction = $promoDetails['price_reduction']; $this->view->message = "Your discount has been applied."; } else { $this->view->message = "You have used a promotion code previously."; } } else { $this->view->message = "This promotion code is not active anymore."; } } if ($purchaseType == 1) { $this->view->workout_rate = $workoutrate['rate_single_workout']; } else { $this->view->workout_rate = $workoutrate['rate_total_workout']; } $this->view->lang = $this->getDefaultLanguage(); }