public function indexAction() { $this->_multi(); $object = Wpjb_Model_Resume::current(); $page = (int) $this->_request->get("page", 1); if ($page < 1) { $page = 1; } $perPage = $this->_getPerPage(); $query = new Daq_Db_Query(); $query->select()->from("Wpjb_Model_Resume t")->join("t.users t2")->order("t.updated_at DESC"); $prep = clone $query; $show = $this->_request->get("show", "all"); if ($show == "pending") { $query->where("t.is_approved=?", Wpjb_Model_Resume::RESUME_PENDING); } $count = $query->select("COUNT(*) AS cnt")->limit(1)->fetchColumn(); $result = $query->select("*")->limitPage($page, $perPage)->execute(); $this->view->data = $result; $prep->select("COUNT(*) AS cnt")->limit(1); $total = clone $prep; $active = clone $prep; $this->view->show = $show; $stat = new stdClass(); $stat->total = $total->fetchColumn(); $stat->pending = $active->where("t.is_approved=?", Wpjb_Model_Resume::RESUME_PENDING)->fetchColumn(); $this->view->stat = $stat; $this->view->current = $page; $this->view->total = ceil($stat->total / $perPage); }
public function init() { $this->addGroup("apply", "Apply"); $e = new Daq_Form_Element("applicant_name", Daq_Form_Element::TYPE_TEXT); $e->addFilter(new Daq_Filter_Trim()); $e->setLabel(__("Your name", WPJB_DOMAIN)); $e->setRequired(true); $this->addElement($e, "apply"); $e = new Daq_Form_Element("email", Daq_Form_Element::TYPE_TEXT); $e->setLabel(__("Your e-mail address", WPJB_DOMAIN)); $e->setRequired(true); $e->addValidator(new Daq_Validate_Email()); $this->addElement($e, "apply"); $e = new Daq_Form_Element_File("cv_file", Daq_Form_Element::TYPE_FILE); $e->setDestination(Wpjb_List_Path::getPath("apply_file")); $e->setLabel(__("Your CV file", WPJB_DOMAIN)); $this->addElement($e, "apply"); $resume = Wpjb_Model_Resume::current(); $isEmp = get_user_meta(wp_get_current_user()->ID, "is_employer", true); if ($resume->id > 0 && !$isEmp || is_admin()) { $e = new Daq_Form_Element("resume_id", Daq_Form_Element::TYPE_CHECKBOX); $e->setLabel(__("Send my profile resume", WPJB_DOMAIN)); $id = $resume->id; $e->addOption($id, $id, ""); $e->addValidator(new Daq_Validate_InArray(array($id))); $this->addElement($e, "apply"); } $e = new Daq_Form_Element("resume", Daq_Form_Element::TYPE_TEXTAREA); $e->setLabel(__("Your resume/message", WPJB_DOMAIN)); $this->addElement($e, "apply"); $this->_additionalFields(); if (Wpjb_Project::getInstance()->conf("front_enable_protection") == 1) { $e = new Daq_Form_Element("protection", Daq_Form_Element::TYPE_HIDDEN); $e->addValidator(new Daq_Validate_InArray(array(Wpjb_Project::getInstance()->conf("front_protection", "pr0t3ct1on")))); $e->setRequired(true); $this->addElement($e, "hidden"); } elseif (Wpjb_Project::getInstance()->conf("front_enable_protection") == 2) { $e = new Daq_Form_Element("recaptcha_response_field"); $e->setRequired(true); $e->addValidator(new Daq_Validate_Callback("wpjb_recaptcha_check")); $e->setRenderer("wpjb_recaptcha_form"); $e->setLabel(__("Captcha", WPJB_DOMAIN)); $this->addElement($e, "apply"); } apply_filters("wpjb_form_init_apply", $this); $this->setModifiedScheme(Wpjb_Project::getInstance()->conf("form_apply_for_job", true)); }
/** * Payment form which allows to make payment for candidate membership * * Always use this shortcode with pricing_id param for example * [custom_payment_type_form pricing_id="100"] * where 100 is actual ID of pricing created in wp-admin / Settings (WPJB) / Pricing * panel. * * @param array $atts List of shortcode params * @return string Rendered payment form */ function custom_payment_type_form($atts) { $params = shortcode_atts(array("pricing_id" => null), $atts); $flash = new Wpjb_Utility_Session(); $pricing = new Wpjb_Model_Pricing($params["pricing_id"]); if (!$pricing->exists()) { return; } if ($pricing->price_for != 210) { return; } $list = new Wpjb_List_Pricing(); $listing = $list->getBy("id", $pricing->price_for); $view = Wpjb_Project::getInstance()->getApplication("frontend")->getView(); $view->atts = $atts; $view->pricing = $pricing; $view->gateways = Wpjb_Project::getInstance()->payment->getEnabled(); $view->pricing_item = $listing["title"] . " "" . $pricing->title . """; $view->defaults = new Daq_Helper_Html("span", array("id" => "wpjb-checkout-defaults", "class" => "wpjb-none", "data-pricing_id" => $pricing->id, "data-object_id" => Wpjb_Model_Resume::current()->id, "data-fullname" => wp_get_current_user()->display_name, "data-email" => wp_get_current_user()->user_email), " "); Wpjb_Project::getInstance()->placeHolder = $view; wp_enqueue_style("wpjb-css"); wp_enqueue_script('wpjb-js'); ob_start(); $view->render("../default/payment.php"); $render = ob_get_clean(); return $render; }
public function registerAction() { if (!get_option('users_can_register')) { $this->view->_flash->addError(__("User registration is disabled.", WPJB_DOMAIN)); return false; } $object = Wpjb_Model_Resume::current(); if ($object->id > 0) { wp_redirect(wpjr_link_to("myresume")); } $this->_setTitle(__("Register", WPJB_DOMAIN)); $form = new Wpjb_Form_Resumes_Register(); $this->view->errors = array(); if ($this->isPost()) { $isValid = $form->isValid($this->getRequest()->getAll()); if ($isValid) { $username = $form->getElement("user_login")->getValue(); $password = $form->getElement("user_password")->getValue(); $email = $form->getElement("user_email")->getValue(); $id = wp_create_user($username, $password, $email); $instance = Wpjb_Project::getInstance(); $router = $instance->getApplication("resumes")->getRouter(); /* @var $router Daq_Router */ $url = $instance->getApplication("resumes")->getUrl(); $url .= "/" . $router->linkTo("myresume"); $mail = new Wpjb_Utility_Message(10); $mail->setTo($email); $mail->setParam("username", $username); $mail->setParam("password", $password); $mail->setParam("login_url", $url); $mail->send(); $this->view->_flash->addInfo(__("You have been registered.", WPJB_DOMAIN)); $form = new Wpjb_Form_Resumes_Login(); $form->isValid(array("user_login" => $username, "user_password" => $password, "remember" => 0)); $redirect = wpjr_link_to("myresume"); wp_redirect($redirect); die; } else { $this->view->_flash->addError(__("There are errors in your form.", WPJB_DOMAIN)); } } $this->view->form = $form; return "register"; }
public function applyAction() { $text = Wpjb_Project::getInstance()->conf("seo_apply", __("Apply for position: {job_title} (ID: {id})", WPJB_DOMAIN)); $param = array('job_title' => $this->getObject()->job_title, 'id' => $this->getObject()->id); $this->_setTitle($text, $param); $job = $this->getObject(); $this->view->job = $job; if (!$this->isMember() && Wpjb_Project::getInstance()->conf("front_apply_members_only", false)) { $this->view->members_only = true; $this->view->_flash->addError(__("Only registered members can apply for jobs.", WPJB_DOMAIN)); return; } if ($job->job_source == 3) { wp_redirect($job->company_website); } $form = new Wpjb_Form_Apply(); if ($this->isPost()) { if ($form->isValid($this->getRequest()->getAll())) { // send $var = $form->getValues(); $job = $this->getObject(); $form->setJobId($job->getId()); $form->setUserId(Wpjb_Model_Resume::current()->user_id); $form->save(); $files = $form->getFiles(); $application = $form->getObject(); $mail = new Wpjb_Model_Email(6); $append = array("applicant_email" => $var['email'], "applicant_cv" => $var['resume'], "applicant_name" => $var['applicant_name']); list($title, $body) = Wpjb_Utility_Messanger::parse($mail, $job, $append); $add = $form->getAdditionalText(); if (!empty($add)) { $body .= "\r\n--- --- ---\r\n"; } foreach ($add as $field) { if (!$form->hasElement($field)) { continue; } $opt = $form->getElement($field)->getOptions(); if (!empty($opt)) { foreach ($opt as $o) { if ($o["value"] == $form->getElement($field)->getValue()) { $fValue = $o["desc"]; } } } else { $fValue = $form->getElement($field)->getValue(); } $body .= $form->getElement($field)->getLabel() . ": "; $body .= $fValue . "\r\n"; } $headers = "From: " . $var["applicant_name"] . " <" . $var["email"] . ">\r\n"; $email = $var["email"]; $title = trim($title); if (empty($title)) { $title = __("[Application] ", WPJB_DOMAIN) . $var["name"]; } if (apply_filters("wpjb_job_apply", $form) !== true) { wp_mail($job->company_email, $title, $body, $headers, $files); } $form->reinit(); $job->stat_apply++; $job->save(); $this->view->application_sent = true; $this->view->_flash->addInfo(__("Your application has been sent.", WPJB_DOMAIN)); Wpjb_Utility_Messanger::send(8, $job, array('applicant_email' => $var['email'])); } else { $this->view->_flash->addError(__("There are errors in your form.", WPJB_DOMAIN)); } } elseif (Wpjb_Model_Resume::current()->id > 0) { $resume = Wpjb_Model_Resume::current(); if ($form->hasElement("email")) { $form->getElement("email")->setValue($resume->email); } if ($form->hasElement("applicant_name")) { $form->getElement("applicant_name")->setValue($resume->firstname . " " . $resume->lastname); } } $this->view->form = $form; }