public function launchAction() { //echo "launch"; die; global $mySession; $db = new Db(); $this->_helper->layout->setLayout('main'); $cid = $this->getRequest()->getParam('cid'); $lid = $this->getRequest()->getParam('lid'); //$myform=new Form_Setgoal(); $this->view->lid = $lid; $this->view->cid = $cid; //echo "camp id : when launched :".$cid; die; //echo "JSK last id : ".$lid; die; $myform = new Form_Adddescription(); $this->view->myform = $myform; if ($this->getRequest()->isPost()) { $request = $this->getRequest(); $myform = new Form_Adddescription(); if ($myform->isValid($request->getPost())) { $dataForm = $myform->getValues(); //echo "inside post"; //$checkboxval=$_REQUEST['add_checkbox']; //echo "value of CB===".$checkboxval; die; //pr($dataForm); $myObj = new Launchcampaigndb(); if ($mySession->camptitl != "" && $mySession->setgoalvalues != "" && $mySession->showurl != "") { //echo $mySession->campaign_category."JSK"; prd($mySession); //echo "launch action session values"; die; $data1 = $myObj->saveall(); #get followers $followers = ''; $getfollowers = $db->runquery("select * from " . FOLLOW . " where following_id='" . $mySession->TeeLoggedID . "' "); if (count($getfollowers) > 0) { foreach ($getfollowers as $follow) { $followers .= $follow['follower_id'] . ","; } #save for notification $savenotification = array('n_camp_id' => $data1, 'n_user_id' => $followers, 'n_date' => date('Y-M-d H:i:s')); $db->save(NOTIFICATION, $savenotification); $campvalue = $db->runQuery("select title,url,campaign_id from " . LAUNCHCAMPAIGN . " where campaign_id='" . $data1 . "'"); $urlPathcapmp = '<a href="' . APPLICATION_URL . urlencode($campvalue[0]['url']) . '">' . APPLICATION_URL . urlencode($campvalue[0]['url']) . '</a>'; $DatauserDetail = $db->runQuery("select * from " . USERS . " where user_id='" . $mySession->TeeLoggedID . "'"); $urlPathprofile = '<a href="' . APPLICATION_URL . 'user/view/user_id/' . $DatauserDetail[0]['user_id'] . '">' . APPLICATION_URL . 'user/view/user_id/' . $DatauserDetail[0]['user_id'] . '</a>'; foreach ($getfollowers as $follow) { $Data = $db->runQuery("select * from " . USERS . " where user_id='" . $follow['follower_id'] . "'"); $emaid = $Data[0]['emailid']; $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='19'"); $messageText = $templateData[0]['email_body']; $subject = $templateData[0]['email_subject']; $messageText = str_replace("[NAME]", $emaid, $messageText); $messageText = str_replace("[UNAME]", $DatauserDetail[0]['emailid'] . '(' . $DatauserDetail[0]['public_name'] . ')', $messageText); $messageText = str_replace("[CAMPAIGN_TITLE]", $campvalue[0]['title'] . '', $messageText); $messageText = str_replace("[CAMPAIGN_LINK]", $urlPathcapmp, $messageText); $messageText = str_replace("[PROFILE_LINK]", $urlPathprofile, $messageText); $messageText = str_replace("[SITENAME]", SITE_NAME, $messageText); SendEmail($emaid, $subject, $messageText); } $this->_redirect(APPLICATION_URL . urlencode($dataForm['url'])); } } if ($cid != "") { //echo "here is cid ".$cid; die; $data = $myObj->relaunchcampaign($dataForm, $cid); } else { //echo "JSK last id : ".$lid; die; $data = $myObj->savecampaign($dataForm, $lid); #get followers $followers = ''; $getfollowers = $db->runquery("select * from " . FOLLOW . " where following_id='" . $mySession->TeeLoggedID . "' "); if (count($getfollowers) > 0) { foreach ($getfollowers as $follow) { $followers .= $follow['follower_id'] . ","; } #save for notification $savenotification = array('n_camp_id' => $lid, 'n_user_id' => $followers, 'n_date' => date('Y-M-d H:i:s')); $db->save(NOTIFICATION, $savenotification); $campvalue = $db->runQuery("select title,url,campaign_id from " . LAUNCHCAMPAIGN . " where campaign_id='" . $lid . "'"); $urlPathcapmp = '<a href="' . APPLICATION_URL . urlencode($campvalue[0]['url']) . '">' . APPLICATION_URL . urlencode($campvalue[0]['url']) . '</a>'; $DatauserDetail = $db->runQuery("select * from " . USERS . " where user_id='" . $mySession->TeeLoggedID . "'"); $urlPathprofile = '<a href="' . APPLICATION_URL . 'user/view/user_id/' . $DatauserDetail[0]['user_id'] . '">' . APPLICATION_URL . 'user/view/user_id/' . $DatauserDetail[0]['user_id'] . '</a>'; foreach ($getfollowers as $follow) { $Data = $db->runQuery("select * from " . USERS . " where user_id='" . $follow['follower_id'] . "'"); $emaid = $Data[0]['emailid']; $templateData = $db->runQuery("select * from " . EMAIL_TEMPLATES . " where template_id='19'"); $messageText = $templateData[0]['email_body']; $subject = $templateData[0]['email_subject']; $messageText = str_replace("[NAME]", $emaid, $messageText); $messageText = str_replace("[UNAME]", $DatauserDetail[0]['emailid'] . '(' . $DatauserDetail[0]['public_name'] . ')', $messageText); $messageText = str_replace("[CAMPAIGN_TITLE]", $campvalue[0]['title'] . '', $messageText); $messageText = str_replace("[CAMPAIGN_LINK]", $urlPathcapmp, $messageText); $messageText = str_replace("[PROFILE_LINK]", $urlPathprofile, $messageText); $messageText = str_replace("[SITENAME]", SITE_NAME, $messageText); SendEmail($emaid, $subject, $messageText); } } // $db->save(LAUNCHCAMPAIGN,$data_insert); } //echo "else";die; if ($data == 1) { // X001 Preparing the parameters $postvals = $request->getPost(); $payment_params = array("lid" => $lid, "creator" => $mySession->TeeLoggedID, "length" => $postvals["no_ofdays"], "tees" => $mySession->no_of_t, "baseprice" => 0, "sellprice" => $mySession->setgoalvalues["sellingprice"], "url" => $postvals["url"], "valuekm" => $mySession->selectedIdValueKM); // End of X001 $mySession->errorMsg = "Campaign Launched successfully"; $sql = $db->runquery("select * from " . LAUNCHCAMPAIGN . " where user_id='" . $mySession->TeeLoggedID . "' and draft_status='1'"); //echo "select * from ".LAUNCHCAMPAIGN." where user_id='".$mySession->TeeLoggedID."'"; //echo "url is: ".$dataForm['url']; die; $mySession->setgoalvalues = ""; unset($mySession->setgoalvalues); $mySession->no_of_t = ""; unset($mySession->no_of_t); $mySession->baseprice = ""; unset($mySession->baseprice); $mySession->camptitl = ""; unset($mySession->camptitl); $mySession->descrip = ""; unset($mySession->descrip); $mySession->camplength = ""; unset($mySession->camplength); $mySession->showurl = ""; unset($mySession->showurl); $mySession->campaign_category = ""; unset($mySession->campaign_category); $mySession->recreation_product = ""; unset($mySession->recreation_product); $mySession->setBackImageIcon = ""; unset($mySession->setBackImageIcon); $mySession->setFrontImageIcon = ""; unset($mySession->setFrontImageIcon); $mySession->customimage = ""; unset($mySession->customimage); $mySession->dataURLDbback = ""; unset($mySession->dataURLDbback); $mySession->dataURLDbfront = ""; unset($mySession->dataURLDbfront); //$this->_redirect('launchcampaign/showcampaign/name/'.$dataForm['url']); // X002 getting parameters require_once dirname(dirname(__FILE__)) . '/configs/crowdfunding.inc.php'; require_once dirname(dirname(__FILE__)) . '/crowdfunding/Crowdfunding.php'; $sel = $db->runquery("select * from " . TSHIRT_PRICE . " where campagin_id='" . $payment_params["valuekm"] . "'"); $sql = $db->runquery("select * from " . TSHIRT_DISCOUNT . " where no_of_tee='" . $payment_params["tees"] . "'"); if (count($sql) > 0) { $bprice = $sel[0]['base_price'] * $sql[0]['discount_per'] / 100; $bprice = $sel[0]['base_price'] - $bprice; } else { $sql1 = $db->runquery("select * from " . TSHIRT_DISCOUNT . " where no_of_tee <'" . $payment_params["tees"] . "' && no_of_tee!=0"); $cnt = count($sql1); $discount = $sql1[$cnt - 1]['discount_per']; $bprice = $sel[0]['base_price'] * $discount / 100; $bprice = $sel[0]['base_price'] - $bprice; } $payment_params["baseprice"] = $bprice; $crowdfunding = new Crowdfunding(); $crowdfunding->create_campaign($payment_params); // End of X002 $this->_redirect(APPLICATION_URL . urlencode($dataForm['url'])); } } else { //echo"else of in valid"; $this->view->myform = $myform; $this->render('adddescription'); } } else { //echo"else of is post"; die; $this->_redirect('launchcampaign/adddescription'); } //pr($mySession->camplength); //prd($mySession->showurl); }