Esempio n. 1
0
<?php

include $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
Security::demand(USER);
$foretag = Foretag::loadById($_POST["fid"]);
$foretag->gaMedI($_POST["nyckel"]);
header("Location: " . $urlHandler->getUrl("Foretag", URL_VIEW, $foretag->getId()));
Esempio n. 2
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
$smarty = new AdminSmarty();
$foretag = Foretag::loadById($_GET["fid"]);
$smarty->assign("foretag", $foretag);
$smarty->display('editforetag.tpl');
Esempio n. 3
0
 public function getForetag()
 {
     if (!$this->foretag) {
         $this->foretag = Foretag::loadById($this->foretag_id);
     }
     return $this->foretag;
 }
Esempio n. 4
0
 unset($lag_stegtotal_cache);
 if (count($tl) != 0) {
     array_multisort($tl, SORT_DESC);
 }
 $tm = array();
 if (empty($foretag_ids)) {
     $foretag_ids = array();
     foreach ($tf as $foretag) {
         $foretag_ids[] = $foretag["id"];
     }
 }
 $sql = "SELECT foretag_id, medlem_id, aNamn FROM " . Foretag::KEY_TABLE . " f INNER JOIN " . Medlem::TABLE . " m ON f.medlem_id=m.id WHERE medlem_id > 0 AND foretag_id IN (" . implode(",", $foretag_ids) . ")";
 $res = $db->query($sql);
 while ($row = mysql_fetch_array($res)) {
     try {
         $tForetag = Foretag::loadById($row["foretag_id"]);
         $medlem_id = $row["medlem_id"];
         $medlem_anamn = $row["aNamn"];
     } catch (Exception $e) {
         // Foretag doesn't exist (we check this just in case)
         continue;
     }
     if (!empty($medlem_id)) {
         $stegindex = Medlem::getStegIndexForMedlemId($medlem_id, $tForetag);
         if ($tForetag != null && $stegindex != null && strtotime($tForetag->getSlutDatum()) >= $slutDatum_ts) {
             $tm[] = array("stegindex" => $stegindex, "namn" => $medlem_anamn, "id" => $medlem_id);
         }
     }
 }
 unset($tForetag);
 unset($medlem_stegtotal_cache);
Esempio n. 5
0
<?php

include $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
include '../php/libs/php-ofc-library/open-flash-chart.php';
$medlemGraf = array();
$mabraGraf = array();
if (!empty($_GET['lid'])) {
    $lag = Lag::loadById($_GET['lid']);
} elseif (!empty($_GET['fid'])) {
    $foretag = Foretag::loadById($_GET['fid']);
} elseif (!empty($_GET['gid'])) {
    $klubb = Grupp::loadById($_GET['gid']);
} else {
    if ($_GET["id"] > 0) {
        $medlem = Medlem::loadById($_GET["id"]);
    } else {
        $medlem = $USER;
    }
}
$max_steg = 0;
$y_labels = array();
// generate some random data
srand((double) microtime() * 1000000);
$bar = new bar_outline(100, '#00ADDF', '#4AABCB');
$data = array();
$veckodagar = array("Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag");
$x_labels = array();
for ($i = -7; $i <= 0; $i++) {
    if (isset($medlem)) {
        $steg = Steg::getTotalStegByDay($i, $medlem);
    } elseif (isset($lag)) {
Esempio n. 6
0
         }
         if (strlen($antal) > 0) {
             $antal = substr($antal, 0, strlen($antal) - 1);
         }
         //Order::krilloLogToFile("refid: $refId, kampanjkod: $kampanjkod, antal: $antal");
         //$objekt->genereraLag();
         $order->gorUppslag($kampanjkod, $antal);
         //send the order
     } else {
         throw new OrderException("", -1);
     }
     break;
 case isset($_REQUEST["typ"]) && $_REQUEST["typ"] == "foretag_again":
     // renewal of company contest
     $typ = "foretag_again";
     $objekt = Foretag::loadById($_REQUEST["fid"]);
     $kontotyp = "RE04";
     $antal = $objekt->getAntalAnstallda();
     $order = new Order($typ, $objekt, $kontotyp, $antal, $kanal, $compAffCode, 0);
     $order->setForetag($objekt);
     $order->setCompanyName($objekt->getNamn());
     $order->commit();
     $order->gorUppslag();
     break;
 default:
     $errMess = "Felaktig ordertyp ";
     if (isset($_REQUEST["typ"])) {
         $errMess = $errMess . "  ->" . $_REQUEST["typ"] . "<-";
     }
     throw new OrderException($errMess, -1);
     break;
Esempio n. 7
0
            //print_r($allaLag);
            //get all members for the submitted company
            //Deltagartoppen  no limit - all members (-1)
            $allCompMembArray = Tavling::getResultAllMembers($tid, -1, $fid);
            //print_r($allCompMembArray);
            //get all members for the whole contest    Deltagartoppen
            //if the member ranks lower than DELTAGARTOPPEN_MAX then add her the the array
            $allMembArray = Tavling::getResultAllMembers($tid, DELTAGARTOPPEN_MAX);
            //print_r($allMembArray);
            $lagArray = Tavling::getResultTeam($tid);
            //get all the teams with median  Lagtoppen
            //print_r($foretagLagArray);
            $allForetagArray = Tavling::getResultCompany($tid, FORETAGSTOPPEN_MAX);
            //get all companys average   Foretagstoppen
            //print_r($allForetagArray);
            $foretag = Foretag::loadById($fid);
            break;
        default:
            throw new UserException('Något har gått fel', 'Prova igen senare eller rapportera felet till support@motiomera.se');
            break;
    }
}
$smarty->assign("foretagArray", $foretagArray);
$smarty->assign("allaLag", $allaLag);
$smarty->assign("foretagLagArray", $foretagLagArray);
$smarty->assign("allCompMembArray", $allCompMembArray);
$smarty->assign("allMembArray", $allMembArray);
$smarty->assign("lagArray", $lagArray);
$smarty->assign("allForetagArray", $allForetagArray);
//these two highlites the user on tavlingsresultat.php !?!?
$smarty->assign("tavlingsresultatsidan", true);
Esempio n. 8
0
 /**
  * Försöker logga in med epost och lösenord.
  * Om det lyckas så sparas data om vem som är inloggad, och ett Medlems-objekt returneras
  *
  * @global  $db
  * @param type $epost
  * @param type $losenord
  * @param type $cookie
  * @return boolean
  * @throws MedlemException 
  */
 public static function loggaIn($epost, $losenord, $cookie = false)
 {
     global $db;
     $epost = Security::secure_postdata($epost);
     $losenord = Security::secure_postdata($losenord);
     if ($epost == "" || $losenord == "") {
         return false;
     }
     $sql = "SELECT id\n\t\t\t\tFROM " . self::classToTable(get_class()) . " \n\t\t\t\tWHERE epost='{$epost}'";
     $id = $db->value($sql);
     if ($id == "") {
         throw new MedlemException('E-postadressen kunde inte hittas', -13);
     }
     $medlem = Medlem::loadById($id);
     if ($medlem->epostBekraftad == 0) {
         throw new MedlemException('Kontot ej aktiverat', -15);
     }
     $losenordKrypterat = Security::encrypt_password($id, $losenord);
     if ($losenordKrypterat == $medlem->getLosenord()) {
         // Lyckad inloggning
         $sessionId = self::generateSessionId();
         $medlem->setSenastInloggad();
         $medlem->setSessionId($sessionId);
         $medlem->commit();
         $_SESSION["mm_mid"] = $id;
         $_SESSION["mm_sid"] = $sessionId;
         if ($cookie) {
             setcookie("mm_mid", $id, time() + 60 * 60 * 24 * 30, "/");
             setcookie("mm_sid", $sessionId, time() + 60 * 60 * 24 * 30, "/");
         }
         //if foretags_id in db, try to log in as foretagsadmin
         $fId = $medlem->getFadmin();
         if ($fId > 0) {
             $foretag = Foretag::loadById($fId);
             $foretag->doubleLogIn($fId);
         }
         // if levelId is set (ie, the member used to be a pro), it gets reset to zero, and an exception is thrown (which leads to to the user being redirected to the buy page)
         if ($medlem->getPaidUntil() < date("Y-m-d")) {
             // && $medlem->getLevelId() > 0) {   //old stuff removed by krillo 2011-01-19,  always lock them out
             $level = $medlem->getLevelId();
             //$medlem->setLevelId(0);
             //$medlem->commit();
             throw new MedlemException('Medlemskap har gått ut', -19, $level);
         }
         return true;
     } else {
         throw new MedlemException("Felaktigt lösenord", -5);
     }
 }
Esempio n. 9
0
!empty($_REQUEST['city']) ? $order->city = $_REQUEST['city'] : ($order->city = '');
!empty($_REQUEST['country']) ? $order->country = $_REQUEST['country'] : ($order->country = '');
$order->street = $order->street1;
!empty($order->street2) ? $order->street = $order->street . ' ' . $order->street2 : null;
!empty($order->street3) ? $order->street = $order->street . ' ' . $order->street3 : null;
$redirPage = $SETTINGS["url"] . "/pages/foretag_kampanj.php?anamn=" . $order->anamn . "&mailone=" . $order->email . '&firstname=' . $order->fname . '&lastname=' . $order->lname . '&co=' . $order->co . '&phone=' . $order->phone . '&street1=' . $order->street1 . '&street2=' . $order->street2 . '&street3=' . $order->street3 . '&zip=' . $order->zip . '&city=' . $order->city;
if ($order->compcampcode == '' or $order->email == '' or $order->fname == '' or $order->lname == '') {
    Misc::logMotiomera("Error action/medlem_foretagskod.php  Fält saknas!  \n Params:\n" . print_r($order, true) . "\n ", 'ERROR');
    $redirPage .= "&msg=fields_missing";
    header('Location: ' . $redirPage);
}
$companyId = Foretag::getCompanyIdByCampaignMemberCode($order->compcampcode);
if (is_numeric($companyId) && $companyId > 0) {
    //everthing looks fine sofar, create the user
    try {
        $foretag = Foretag::loadById($companyId);
        $kommun = Kommun::loadById($order->kid);
        $kontotyp = '';
        //legacy or not used right now
        $maffcode = '';
        //legacy or not used right now
        $medlem = new Medlem($order->email, $order->anamn, $kommun, $order->sex, $order->fname, $order->lname, $kontotyp, $maffcode);
        $medlem->confirm($order->pass);
        $medlem->setAddress($order->street);
        $medlem->setCo($order->co);
        $medlem->setZip($order->zip);
        $medlem->setCity($order->city);
        $medlem->setPhone($order->phone);
        $medlem->setCountry($order->country);
        $medlem->setEpostBekraftad(1);
        //medlem valid
Esempio n. 10
0
 public static function getTopplistaForetag($limit = null)
 {
     global $db;
     $l = "";
     //limiter
     if ($limit != null) {
         $l = " LIMIT {$limit}";
     }
     $sql = "SELECT sum(steg) AS steg, a.id FROM mm_foretag a, mm_foretagsnycklar b, mm_steg c \n\t\t\tWHERE c.medlem_id = b.medlem_id\n\t\t\tAND a.id = b.foretag_id \n\t\t\tGROUP BY a.id ORDER BY steg DESC" . $l;
     $foretagList = $db->valuesAsArray($sql);
     //$foretagList = Foretag::listAll();
     $topplista = array();
     foreach ($foretagList as $row) {
         if ($row['id'] != 0) {
             $topplista[] = Foretag::loadById($row['id']);
         }
     }
     //ksort($topplista);
     $topplista = array_reverse($topplista);
     /* $topplista2 = array();
        foreach($topplista as $pos){
        foreach($pos as $ftag)
        $topplista2[] = $ftag;
        } */
     return $topplista;
 }
Esempio n. 11
0
/**
 * Description: set the fadmin
 * The data is returned as a jason object in the format below:
 *
 * Date: 2013-09-02
 * Author: Kristian Erendi
 * URI: http://reptilo.se
 */
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
require_once $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
$req = new stdClass();
!empty($_REQUEST['mm_id']) ? $req->mm_id = addslashes($_REQUEST['mm_id']) : ($req->mm_id = '');
!empty($_REQUEST['fid']) ? $req->fid = addslashes($_REQUEST['fid']) : ($req->fid = '');
$response['success'] = 0;
try {
    $foretag = Foretag::loadById($req->fid);
    $reset = $foretag->resetAllFadmin();
    if ($reset) {
        $medlem = Medlem::loadById($req->mm_id);
        $medlem->setFadmin($req->fid);
        $medlem->commit();
        $response['success'] = $req->mm_id;
    }
} catch (Exception $exc) {
    $response['error'] = $exc->getTraceAsString();
}
echo json_encode($response);
die;
Esempio n. 12
0
!empty($_REQUEST['m_incmoms']) ? $order->incmoms = $_REQUEST['m_incmoms'] : ($order->incmoms = 0);
!empty($_REQUEST['startdatumRadio']) ? $order->startdatumRadio = $_REQUEST['startdatumRadio'] : ($order->startdatumRadio = 0);
!empty($_REQUEST['discount']) ? $order->discount = $_REQUEST['discount'] : ($order->discount = '');
!empty($_REQUEST['RE03']) ? $order->RE03 = $_REQUEST['RE03'] : ($order->RE03 = 0);
!empty($_REQUEST['RE04']) ? $order->RE04 = $_REQUEST['RE04'] : ($order->RE04 = 0);
!empty($_REQUEST['fid']) ? $order->fid = $_REQUEST['fid'] : ($order->fid = 0);
!empty($_REQUEST['paytype']) ? $order->paytype = $_REQUEST['paytype'] : ($order->paytype = '');
!empty($_REQUEST['channel']) ? $order->channel = $_REQUEST['channel'] : ($order->channel = '');
!empty($_REQUEST['campcode']) ? $order->campcode = $_REQUEST['campcode'] : ($order->campcode = '');
!empty($_REQUEST['refcode']) ? $order->refcode = $_REQUEST['refcode'] : ($order->refcode = '');
$order->RE03 = (int) $order->RE03;
$order->RE04 = (int) $order->RE04;
$order->exmoms = (int) $order->exmoms;
$order->total = (int) $order->total;
$order->incmoms = round($order->incmoms, 2);
$foretag = Foretag::loadById($order->fid);
$order->email = $foretag->getPayerEmail();
$order->fname = $foretag->getPayerFName();
$order->lname = $foretag->getPayerLName();
$order->company = $foretag->getNamn();
if ($order->RE03 == 0 && $order->RE04 == 0) {
    //return to checkout
    $url = $SETTINGS["url"] . '/pages/editforetag.php?fid=' . $order->fid . '&tab=' . $order->fid;
    header('Location: ' . $url);
    exit;
} else {
    //do a price check to avoid javascript hacking
    $noFraud = Order::priceCheck($order->RE03, $order->RE04, $order->exmoms, $order->freight, $order->total, $order->incmoms, $order->discount);
    if ($noFraud) {
        //javascript prices match to local calculation
        $token = null;
Esempio n. 13
0
 public function addRad($text)
 {
     global $USER;
     if ($this->getForetagId()) {
         $foretag = Foretag::loadById($this->getForetag());
         if (!isset($USER) || !$foretag->arMedI($USER)) {
             throw new UserException("Ej medlem", "Du är ej medlem i denna klubb och kan därför inte skriva på dess anslagstavla.");
         }
     } else {
         if ($this->getGruppId() > 0) {
             $grupp = Grupp::loadById($this->getGruppId());
         } else {
             $grupp = Lag::loadById($this->getLagId());
         }
         if (!isset($USER) || !$grupp->isMember($USER)) {
             throw new UserException("Ej medlem", "Du är ej medlem i denna klubb och kan därför inte skriva på dess anslagstavla.");
         }
     }
     new AnslagstavlaRad($this->id, $USER->getId(), $text);
 }