Location: PHPKode > projects > PhpChrystal - An Open Intranet System > 0.071Alpha1/phpOrdering.php
<?php
  session_start();
  session_set_cookie_params('32758');

  // XML::MODUL   (phpOrdering)
  // XML::VERSION (0.071 Alpha1)
  // XML::AUTHOR  (::[CTH]Goldenhawk::)
  // XML::INFO    (Anzeige und Verwaltung der Bestellungen)


  // XML::COMMENT (Vesrion, Name und Autor festlege)
  $PLUGIN_VERSION = "0.071 Alpha1";
  $PLUGIN_NAME    = "phpOrdering";
  $PLUGIN_AUTHOR  = "::[CTH]Goldenhawk::";

  // XML::COMMENT (Session-Variablen vorher festlegen, ansonsten gehts net)
  if ($_GET['cmd'] == 'cmd_userupdate')
  {
    if ($_GET['action'] == 'addDatabaseArticles')
    {
      if ($_GET['iArticleID'] && $_POST['in_iAmount'])
        $_SESSION['arBoughtDatabase'][$_GET['iArticleID']] = $_POST['in_iAmount'];
    }
    elseif ($_GET['action'] == 'addTemplateArticles')
    {
      for ($iCnt = 1;$iCnt < $_GET['iMaximum'];$iCnt++)
      {
        if ($_POST['in_iArticleID_'.$iCnt] && $_POST['in_iAmount_'.$iCnt])
        {
          $_SESSION['arBoughtTemplate'][$_POST['in_iArticleID_'.$iCnt]] = $_POST['in_iAmount_'.$iCnt];
        }
      }
    }
    elseif ($_GET['action'] == 'deleteSessionArticles')
    {
      if ($_GET['bIsDatabaseArticle'])
        unset($_SESSION['arBoughtDatabase'][$_GET['iArticleID']]);
      else
        unset($_SESSION['arBoughtTemplate'][$_GET['iArticleID']]);
    }
    elseif ($_GET['action'] == 'doOrder')
    {
      $arTempSession['arBoughtDatabase'] = $_SESSION['arBoughtDatabase'];
      $arTempSession['arBoughtTemplate'] = $_SESSION['arBoughtTemplate'];

      unset($_SESSION['arBoughtDatabase'],$_SESSION['arBoughtTemplate']);

      global $arTempSession;
    }
  }

  // XML::COMMENT (Variablen laden)
  include_once("./classes/CCore.php");

  // XML::FUNC::getInfo ($self->getInfo())
  // XML::DESC::getInfo (liefert Name, Autor und Version des Modules zurück)
  // XML::VERSION::getInfo  (1.0)
  // XML::RETURN::getInfo ($PLUGIN_NAME,$PLUGIN_AUTHOR,$PLUGIN_VERSION)
  function getInfo()
  {
    global $PLUGIN_VERSION,$PLUGIN_NAME,$PLUGIN_AUTHOR;

    return $PLUGIN_NAME;
    return $PLUGIN_AUTHOR;
    return $PLUGIN_VERSION;
  }

  // XML::COMMENT (Template initalisieren)
  $cdesign->initalizeTemplate($arNoOpts);

  // XML::COMMENT (-----------------------------)
  // XML::COMMENT (------ Ausgaberoutinen ------)
  // XML::COMMENT (-----------------------------)

  unset($arOpts);

  // XML::COMMENT (Sicherheitsabfrage, ob der User dem System bekannt ist)
  $csecure->checkUserIsLogedIn($_SESSION['active_userid']);

  // XML::COMMENT (Bestellungen anzeigen)
  if ($_GET['cmd'] == 'show_articles')
  {
    // XML::COMMENT (Template-Datei festlegen)
	$cftpl->doFastParsing(array('absTemplateFile' => 'phpOrdering.overview.tpl', 'arDesign' => $design));

	if (!$_GET['iCategoryID'] && !$_GET['iOrderServiceID'])
	{
	  $cdesign->createTextTree($arNoOpts,array('root' => "<a href=\"$PHP_SELF?cmd=show_articles\">".$cxml->printString($lang['show.articles.root.1'])."</a>",
	  											'1' => array(
															"<a href=\"$PHP_SELF?cmd=show_warenkorb\">".$cxml->printString($lang['show.articles.root.2'])."</a>",
												   		 )
											));

  	  $arTemplate['szNextOrdering'] = $cxml->printString($lang['show.articles.next_order'],$cevent->convertTSToDB($settings['lan.ordering.next']));
      $arTemplate['szPureNextOrdering'] = $cevent->convertTSToDB($settings['lan.ordering.next']);
      $arTemplate['szHint'] = $cxml->printString($lang['show.articles.hint.2']);

      $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockOrderingOverviewTop', 'arTemplate' => $arTemplate)));

      if ($settings['lan.ordering.template.use'])
      {
		$arTemplate['iMaximum']			= 6;
	    $arTemplate['formStart']  		= $cl->FormNew("$PHP_SELF?cmd=cmd_userupdate&amp;action=addTemplateArticles&amp;iMaximum=".$arTemplate['iMaximum'],"return");
	    $arTemplate['formEnd']    		= $cl->FormClose();
	    $arTemplate['formSubmit'] 		= $cl->FormSubmitButtonPure($cxml->printString($lang['show.articles.form.addTemplateArticles']));
        $arTemplate['szHint'] 			= $cxml->printString($lang['show.articles.hint'],$settings['lan.ordering.template.file']);
		$arTemplate['szArticleID']		= $cxml->printString($lang['show.articles.subject.article_id']);
		$arTemplate['szAmount']			= $cxml->printString($lang['show.articles.subject.amount']);

        $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockOrderingFormTemplatesTop', 'arTemplate' => $arTemplate)));

        for ($iCnt = 1;$iCnt<$arTemplate['iMaximum'];$iCnt++)
        {
          $arTemplate['formInputArticleID'] = $cl->createInput(array('type' => 'text', 'name' => 'in_iArticleID_'.$iCnt));
          $arTemplate['formInputArticleAmount'] = $cl->createInput(array('type' => 'text', 'maxlength' => '2', 'name' => 'in_iAmount_'.$iCnt));

          $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockOrderingFormTemplatesEntries', 'arTemplate' => $arTemplate)));
	  	}

        $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockOrderingFormTemplatesBottom', 'arTemplate' => $arTemplate)));
      }

      if ((!$settings['lan.ordering.template.use']) || (($settings['lan.ordering.template.use']) && ($settings['lan.ordering.template.loaddbarticles'])))
      {
        if ($settings['lan.financial.virtkonto.activated'])
        {
          $arTemplate['szYourKonto'] = $cxml->printString($lang['show.articles.your_virtkonto'],$cinfo->getMyVirtKonto($_SESSION['active_userid'])." ".$cxml->printString($lang_def['money_sign']));
          $arTemplate['szPureYourKonto'] = $cinfo->getMyVirtKonto($_SESSION['active_userid'])." ".$cxml->printString($lang_def['money_sign']);

          $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockOrderingVirtKonto', 'arTemplate' => $arTemplate)));
        }


        $arCategories = $corder->getCategories($arNoOpts);
        $arOrderServices = $corder->getOrderServices($arNoOpts);

        $arEntries = array_merge($arCategories,$arOrderServices);

        for ($iCnt = 0;$iCnt<count($arEntries);$iCnt++)
        {
	      // XML::COMMENT (Damit man nette Effekte mit Tabellenhintergründen machen kann)
	      ((!$iChangeCnt) || ($iChangeCnt == 2)) ? ($iChangeCnt = '1') : ($iChangeCnt = '2');

	      $arTemplate[iTwoValues] = $iChangeCnt;
	      $iChangeCnt++;

		  if (!$arEntries[$iCnt]['iCategoryID'])
		  {
		    $arTemplate['szType'] = $cxml->printString($lang['show.articles.orderservice']);
            $arTemplate['szLink'] = "$PHP_SELF?cmd=show_articles&amp;iOrderServiceID=".$arEntries[$iCnt][iOrderServiceID];
		  }
		  else
		  {
		    $arTemplate['szType'] = $cxml->printString($lang['show.articles.category']);
            $arTemplate['szLink'] = "$PHP_SELF?cmd=show_articles&amp;iCategoryID=".$arEntries[$iCnt][iCategoryID];
          }

          $arTemplate['szCategory']	= $arArticleTypes[$iCnt];
          $arTemplate['iArticlesInCategory']	= $corder->getTotalArticles(array('iCategoryID' => $arEntries[$iCnt]['iCategoryID']));
          $arTemplate['szTotalArticles'] 		= $cxml->printString($lang['show.articles.total_articles'],$arTemplate['iArticlesInCategory']);
  	  	  $arTemplate['szNextOrdering'] 		= $cxml->printString($lang['show.articles.next_order'],$cevent->convertTSToDB($arEntries[$iCnt]['tsNextOrder']));
      	  $arTemplate['szPureNextOrdering'] 	= $cevent->convertTSToDB($arEntries[$iCnt]['tsNextOrder']);

          $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockOrderingOverviewCategories', 'arTemplate' => array_merge($arTemplate,$arEntries[$iCnt]))));
        }
      }
	}
	else
	{
	  if ($_GET['iCategoryID'])
	  {
	    $arCategory = $corder->getCategories(array('iCategoryID' => $_GET['iCategoryID']));
	    $absURL = "<a href=\"$PHP_SELF?cmd=show_articles&amp;iCategoryID=".$_GET['iCategoryID']."\">".$cxml->printString($lang['show.articles.root.3'],$arCategory[0]['szName'])."</a>";
	  }
	  else
	  {
	    $arOrderService = $corder->getOrderServices(array('iOrderServiceID' => $_GET['iOrderServiceID']));
	    $absURL = "<a href=\"$PHP_SELF?cmd=show_articles&amp;iOrderServiceID=".$_GET['iOrderServiceID']."\">".$cxml->printString($lang['show.articles.root.4'],$arOrderService[0]['szName'])."</a>";
	  }

	  $cdesign->createTextTree($arNoOpts,array(
											'root' => "<a href=\"$PHP_SELF?cmd=show_articles\">".$cxml->printString($lang['show.articles.root.1'])."</a>",
											'1' => array(
															"<a href = \"$PHP_SELF?cmd=show_warenkorb\">".$cxml->printString($lang['show.articles.root.2'])."</a>",
															$absURL,
												   		 )
										  ));

      $arArticles = $corder->getArticles(array('iCategoryID' => urldecode($_GET['iCategoryID'])));

      for($iCnt=0;$iCnt<count($arArticles);$iCnt++)
      {
	    // XML::COMMENT (Damit man nette Effekte mit Tabellenhintergründen machen kann)
	    ((!$iChangeCnt) || ($iChangeCnt == 2)) ? ($iChangeCnt = '1') : ($iChangeCnt = '2');

	    $arTemplate[iTwoValues] = $iChangeCnt;
	    $iChangeCnt++;

	    $cl->bDisableAcceskey			= 'true';
	    $arTemplate['formStart']  		= $cl->FormNew("$PHP_SELF?cmd=cmd_userupdate&amp;action=addDatabaseArticles&amp;iArticleID=".$arArticles[$iCnt][iArticleID],"return");
	    $arTemplate['formEnd']    		= $cl->FormClose();
	    $arTemplate['formSubmit'] 		= $cl->FormSubmitButtonPure($cxml->printString($lang['show.articles.form.addDatabaseArticles']));
        $arTemplate['szArticleName'] 		= $arArticles[$iCnt][szName];
        $arTemplate['szArticleDesc'] 		= $arArticles[$iCnt][szDesc];
        $arTemplate['szArticleCost'] 		= $cxml->printString($lang['show.articles.cost']).": ".$arArticles[$iCnt][iCost]." ".$cxml->printString($lang_def['money_sign']);
        $arTemplate['szCategory']			= "<a href = '$PHP_SELF?cmd=show_articles&amp;iCategoryID=".$_GET['iCategoryID']."'>".$corder->getEntrySettingForCategory(array('ifEmpty' => '---','sqlRow' => 'szName', 'iCategoryID' => $arArticles[$iCnt]['iCategoryID']))."</a>";
        $arTemplate['szOrderService']		= "<a href = '$PHP_SELF?cmd=show_articles&amp;iOrderServiceID=".$_GET['iOrderServiceID']."'>".$corder->getEntrySettingForOrderService(array('ifEmpty' => '---','sqlRow' => 'szName', 'iOrderServiceID' => $arArticles[$iCnt]['iOrderServiceID']))."</a>";
        $arTemplate['szPureArticleCost'] 	= $arArticles[$iCnt][iCost]." ".$cxml->printString($lang_def['money_sign']);
        $arTemplate['szArticleAmount']  	= $cxml->printString($lang['show.articles.amount']);
        $arTemplate['formInputAmount'] 	= $cl->createInput(array('type' => 'text', 'name' => "in_iAmount", 'value' => '1', 'maxlength' => 2));

        $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockOrderingArticle', 'arTemplate' => array_merge($arTemplate,$arEntries[$iCnt]))));
	  }

      if (!$iCnt)
      {
  		$arTemplate['szMessageNoEntries'] = $cxml->printString($lang['message.no_entries']);

        $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockMessageNoEntries', 'arTemplate' => array_merge($arTemplate,$arEntries[$iCnt]))));
      }
    }
  }
  elseif ($_GET['cmd'] == 'show_warenkorb')
  {
    // XML::COMMENT (Template-Datei festlegen)
	$cftpl->define(array('main' => $cftpl->getTemplatePath('phpOrdering.overview.tpl',$design)));
    $cftpl->assign ($arNoArray);
    $cftpl->parse ('', 'main');

	$cdesign->createTextTree($arNoOpts,array('root' => "<a href=\"$PHP_SELF?cmd=show_articles\">".$cxml->printString($lang['show.articles.root.1'])."</a>",
												'1' => array(
															"<a href=\"$PHP_SELF?cmd=show_warenkorb\">".$cxml->printString($lang['show.articles.root.2'],urlencode($_GET['area']))."</a>",
												   		 )
											));

	$arTemplate['szWarenkorb'] = $cxml->printString($lang['show.warenkorb.subject']);

    $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockWarenkorbFormTop', 'arTemplate' => $arTemplate)));

    if (!$_SESSION['arBoughtDatabase'] && !$_SESSION['arBoughtTemplate'])
    {
      $arTemplate['szMessageNoEntries'] = $cxml->printString($lang['message.no_entries.4']);

      $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockMessageNoEntries', 'arTemplate' => $arTemplate)));
    }
    else
    {
      $iTotalPrice = 0.00;
      $iTotalArticles = 0;

      settype($iTotalPrice,"double");

      if (is_array($_SESSION['arBoughtDatabase']))
      {
        while(list($key,$val) = each($_SESSION['arBoughtDatabase']))
        {
          $arArticle = $corder->getArticles(array('id' => $key));

          $arTemplate['iAmount'] = $val;
		  $arTemplate['szArticleName'] = $arArticle[0][szName];
 		  $arTemplate['szArticleDesc'] = $arArticle[0][szDesc];
		  $arTemplate['iPrice']		 = $arArticle[0][iCost];
		  $arTemplate['iPriceForArticle'] = $cfunc->tryAddFloatingPoints(($arArticle[0][iCost] * $val));
		  $arTemplate['szLink']		 = "$PHP_SELF?cmd=cmd_userupdate&amp;action=deleteSessionArticles&amp;bIsDatabaseArticle=1&amp;iArticleID=".$key;
		  $arTemplate['szDelete']		 = $cxml->printString($lang['show.warenkorb.link.delete']);
		  $arTemplate['cMoneySign']	 = $lang_def['money_sign'];

          $iTotalPrice += $cfunc->tryAddFloatingPoints(($arArticle[0][iCost] * $val));;
		  $iTotalArticles += $val;

          $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockWarenkorbFormEntries', 'arTemplate' => $arTemplate)));
        }
      }

      if (is_array($_SESSION['arBoughtTemplate']))
      {
        while(list($key,$val) = each($_SESSION['arBoughtTemplate']))
        {
          $arTemplate['iAmount'] = $val;
		  $arTemplate['szExtArticleID'] = $key;
 		  $arTemplate['szTemplate'] = $cxml->printString($lang['show.warenkorb.template']);
		  $arTemplate['szLink']		 = "$PHP_SELF?cmd=cmd_userupdate&amp;action=deleteSessionArticles&amp;iArticleID=".$key;
		  $arTemplate['szDelete']		 = $cxml->printString($lang['show.warenkorb.link.delete']);

		  $iTotalArticles += $val;

      	  $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockWarenkorbFormEntriesTemplate', 'arTemplate' => $arTemplate)));
        }
      }

      $arTemplate['iTotalPrice'] 		= $iTotalPrice;
      $arTemplate['szTotalArticles']	= $cxml->printString($lang['show.warenkorb.articles_total'],$iTotalArticles);
      $arTemplate['iTotalArticles'] 	= $iTotalArticles;
      $arTemplate['szTotalPrice']		= $cxml->printString($lang['show.warenkorb.price_total'],$iTotalPrice,$lang_def['money_sign']);
      $arTemplate['cMoneySign'] 		= $lang_def['money_sign'];
	  $arTemplate['formStart']  		= $cl->FormNew("$PHP_SELF?cmd=cmd_userupdate&amp;action=doOrder","return");
	  $arTemplate['formEnd']    		= $cl->FormClose();
	  $arTemplate['formSubmit'] 		= $cl->FormSubmitButtonPure($cxml->printString($lang['show.warenkorb.form.submit']));

      $cl->printOut($cftpl->doFastParsing(array('absBlock' => 'blockWarenkorbFormBottom', 'arTemplate' => $arTemplate)));
    }
  }
  elseif ($_GET['cmd'] == 'user_overview')
  {
    if (!isset($_SESSION['active_userid']))
      $cfunc->faultExt($cxml->printString($lang_def["fault.not_loged_in"]));

    $arOrders = $corder->getOrderingByUser($_SESSION['active_userid']);

    if (is_array($arOrders))
    {
      $desTop[0][text] = $cxml->printString($lang['user.overview.subject.article']);
      $desTop[1][text] = $cxml->printString($lang['user.overview.subject.cost']);
      $desTop[2][text] = $cxml->printString($lang['user.overview.subject.status']);
      $cl->cellsTop($desTop);

      $arStatus = $corder->getStatusTypes();

      for ($iCnt = 0;$iCnt<count($arOrders);$iCnt++)
      {
        if ($arOrders[$iCnt][iArticleID])
          $arArticle = $corder->getArticles(array('id' => $arOrders[$iCnt][iArticleID]));
		else
		{
		  $arArticle[0][szName] = $arOrders[$iCnt][szExtArticleID];
		  $arArticle[0][iCost]	= $cxml->printString($lang_def['unknown']);
		}

        $desOut[0][text] = $arArticle[0][szName];
        $desOut[1][text] = $cxml->printString($lang['user.overview.price'],$cfunc->tryAddFloatingPoints($arArticle[0][iCost] * $arOrders[$iCnt][iAmount]),$lang_def['money_sign']);
        $desOut[2][text] = $arStatus[$arOrders[$iCnt][iStatus]];

		if ($arOrders[$iCnt][iStatus] <= 0)
          $desOut[2][text] .= $cxml->printString($lang['user.overview.link.delete'],$arOrders[$iCnt][iOrderingRefID]);

        $cl->TableText($desOut);
      }
    }
  }
  elseif ($_GET['cmd'] == 'cmd_userupdate')
  {
    if ($_GET['action'] == 'doOrder')
    {
      if (($settings['lan.ordering.template.use'] && $settings['lan.ordering.template.loaddbarticles']) || (!$settings['lan.ordering.template.use']))
      {
    	if ($settings['lan.financial.virtkonto.unloadonordering'])
        {
      	  if (($cinfo->getMyVirtKonto($_SESSION['active_userid']) - $corder->getTotalCostOfOrderingArticles($arTempSession['arBoughtDatabase'])) < 0)
      	  {
        	$cfunc->faultExt($cxml->printString($lang['fault.cost_too_high']));
      	  }
      	  else
      	  {
            $arOpts[iUserID]   = $_SESSION['active_userid'];
            $arOpts[iVirtKonto] = ($cinfo->getMyVirtKonto($_SESSION['active_userid']) - $corder->getTotalCostOfOrderingArticles($arTempSession['arBoughtDatabase']));
      		$cinfo->setUserInfo($arOpts);

        	$desTop = $cxml->printString($lang['message.unloaded']);
      	  }
    	}
  	  }

      $corder->addOrdering(array('arBoughtDatabase' => $arTempSession['arBoughtDatabase'], 'arBoughtTemplate' => $arTempSession['arBoughtTemplate'], 'iUserID' => $_SESSION['active_userid']));

      printDanke($cxml->printString($lang['update.thanks'],$desTop));
    }
    elseif (($_GET['action'] == 'addDatabaseArticles') || ($_GET['action'] == 'addTemplateArticles'))
    {
      printDanke($cxml->printString($lang['update.added'],$desTop));
    }
    elseif ($_GET['action'] == 'deleteSessionArticles')
    {
      printDanke($cxml->printString($lang['update.article_deleted']));
    }
    elseif ($_GET['action'] == 'doDeleteDatabaseOrdering')
    {
      $arOrder = $corder->getOrderingRef(array('iOrderingRefID' => $_GET['iOrderingRefID']));

      if (!is_array($arOrder))
        $cfunc->faultExt($cxml->printString($lang['fault.no_order']));
      elseif ($corder->getUserOfOrderingRefID($_GET['iOrderingRefID']) != $_SESSION['active_userid'])
        $cfunc->faultExt($cxml->printString($lang['fault.not_your_order']));
      elseif ($arOrder[0][iStatus] > 0)
        $cfunc->faultExt($cxml->printString($lang['fault.order_already_in_progress']));
      else
        $corder->deleteOrderingRef($_GET['iOrderingRefID']);

      printDanke($cxml->printString($lang['update.deleted'],$desTop));
    }
  }
  // XML::COMMENT (Administrationsbereich)
  elseif ($_GET['cmd'] == 'admin_overview')
  {
    (!$csecure->verifyUserForAdminArea(array('iUserID' => $_SESSION['active_userid'], 'area' => $PLUGIN_NAME))) ? ($cfunc->faultExt($cxml->printString($lang_def['fault.not_authorized']))) : ($dummy);

    ($settings['lan.ordering.template.use']) ? ($desTop = "checked") : ($desTop = '');
    $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;action=setSettings","");
    $cl->cells2Noopt($cxml->printString($lang['admin.settings.template_use']),"<input type=checkbox value=1 name=in_template_use $desTop>","out");
    ($settings['lan.ordering.template.loaddbarticles']) ? ($desTop = "checked") : ($desTop = '');
    $cl->cells2Noopt($cxml->printString($lang['admin.settings.loaddbarticles']),"<input type=checkbox name=in_template_loaddbarticles value=1 $desTop>","out");
    $cl->cells2Noopt($cxml->printString($lang['admin.settings.template_link']),"<input type=text name=in_template_file value=\"".$settings['lan.ordering.template.file']."\">","out");
    $cl->cells2Noopt($cxml->printString($lang['admin.settiings.next_order']),$cevent->createPreSelectedDateMenu(array('timestamp' => $settings['lan.ordering.next'])).", ".$cevent->createPreSelectedTimeMenu(array('timestamp' => $settings['lan.ordering.next']))." ".$lang_def['time'],"out");

    ($settings['lan.ordering.sendims']) ? ($desTop = "checked") : ($desTop = '');
    $cl->cells2Noopt($cxml->printString($lang['admin.settings.ordering.ims']),"<input type=checkbox name=in_ordering_sendims value=1 $desTop>","out");
    $cl->FormSubmit("2","");
  }
  // XML::COMMENT (Bestellungen anzeigen)
  elseif ($_GET['cmd'] == 'admin_orders')
  {
    (!$csecure->verifyUserForAdminArea(array('iUserID' => $_SESSION['active_userid'], 'area' => $PLUGIN_NAME))) ? ($cfunc->faultExt($cxml->printString($lang_def['fault.not_authorized']))) : ($dummy);

    $cdesign->newCreateTextTree($arNoOpts,
    		array(	$cdesign->createURLLink(array('absURL' => "$PHP_SELF?cmd=admin_orders", 'szContent' => $cxml->printString($lang['admin.tree.overview']), 'bSkipCheck' => 1, 'bNoTarget' => 1)),
			  array(  $cdesign->createURLLink(array('absURL' => "$PHP_SELF?cmd=admin_orders&amp;page=active", 'szContent' => $cxml->printString($lang['admin.tree.orderings_active']), 'bSkipCheck' => 1, 'bNoTarget' => 1)),
			    array(  $cdesign->createURLLink(array('absURL' => "phpContainer.php?cmd=rpc_orderlist", 'szContent' => $cxml->printString($lang['admin.tree.print_active_orders']), 'bSkipCheck' => 1)),
				     ),
					  $cdesign->createURLLink(array('absURL' => "$PHP_SELF?cmd=admin_orders&amp;page=done", 'szContent' => $cxml->printString($lang['admin.tree.orderings_done']), 'bSkipCheck' => 1, 'bNoTarget' => 1)),
				    )
				   ));

    if ($_GET['page'] == 'active')
    {
      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;action=doChangeOrderings","");

      $desText[0][text] = $cxml->printString($lang['admin.overview.action']);
      $desText[1][text] = $cxml->printString($lang['admin.overview.date']);
      $desText[2][text] = $cxml->printString($lang['admin.overview.username']);
      $desText[3][text] = $cxml->printString($lang['admin.overview.detail']);
      $cl->cellsTop($desText);
      unset($desText);

      $arOpts[bOnlyActive] = "1";

      $arOrders = $corder->getOrderings($arOpts);

	  $iTotalCost = 0.00;

      for($iCnt=0;$iCnt<count($arOrders);$iCnt++)
      {
        $arTypes = $corder->getStatusTypes();
	    $arTypes['del'] = $cxml->printString($lang['ar.1.delete']);

        $desText[0][text] = $cdesign->createSelectBox("in_action".$arOrders[$iCnt][id],$arTypes,$arOrders[$iCnt][iStatus],$arNoOpts);
        $desText[1][text] = $cevent->convertTSToDB($arOrders[$iCnt][tsDate]);
        $cl->FormHidden("in_arIDs[]",$arOrders[$iCnt][id]);
        $cl->FormHidden("in_iLastStatus".$arOrders[$iCnt][id],$arOrders[$iCnt][iStatus]);

        ($arSeat = $cseats->getSeatOfUser($arOrders[$iCnt][iUserID])) ? ($desText[2][text] = $cdesign->createLinkNewWindow(array('url' => "phpSeats.php?cmd=show_seats&amp;naked=1&amp;search=".$arSeat[id]."&amp;etage=".$arSeat[level], 'title' => "Interner Sitzplatz ".$arSeat[id], 'content' => $cuser->getUserOfID($arOrders[$iCnt][iUserID])))) : ($desText[2][text] = $cdesign->createUserLink(array('user' => $arOrders[$iCnt][iUserID])));

        $desText[3][text] = "<a href=\"$PHP_SELF?cmd=admin_details&amp;id=".$arOrders[$iCnt][id]."\">".$cxml->printString($lang['admin.overview.link.detail'])."</a>";

        $iTotalCost += $corder->getTotalCostOfOrdering(array('iOrderingID' => $arOrders[$iCnt][id]));

        $cl->TableText($desText);
        unset($desText);
      }

      (!$iCnt) ? (($in[0][text] = $cxml->printString($lang['message.no_entries.2'])) && ($cl->TableText($in))) : (($desText[0][text] = $cxml->printString($lang['message.total_cost'],$cfunc->tryAddFloatingPoints($iTotalCost)." ".$cxml->printString($lang_def['money_sign']))) && ($desText[0][colspan] = 4) && ($cl->TableText($desText)));
      ($iCnt) ? ($cl->FormSubmit("4",$cxml->printString($lang['admin.overview.form']))) : ($dummy);
    }
    elseif ($_GET['page'] == 'done')
    {
      $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;action=deleteOrderings","");

      $desText[0][text] = "&nbsp;";
      $desText[1][text] = $cxml->printString($lang['admin.overview.username']);
      $desText[2][text] = $cxml->printString($lang['admin.overview.detail']);
      $cl->cellsTop($desText);
      unset($desText);

      $arOpts[bOnlyDone] = "1";

      $arOrders = $corder->getOrderings($arOpts);

	  $iTotalCost = 0.00;

      for($iCnt=0;$iCnt<count($arOrders);$iCnt++)
      {
        $desText[0][text] = $cl->createInput(array('type' => 'checkbox', 'name' => 'in_arToDelete[]', 'value' => $arOrders[$iCnt][id]));

        ($arSeat = $cseats->getSeatOfUser($arOrders[$iCnt][iUserID])) ? ($desText[1][text] = $cdesign->createLinkNewWindow(array('url' => "phpSeats.php?cmd=show_seats&amp;naked=1&amp;search=".$arSeat[id]."&amp;etage=".$arSeat[level], 'title' => "Interner Sitzplatz ".$arSeat[id], 'content' => $cuser->getUserOfID($arOrders[$iCnt][iUserID])))) : ($desText[1][text] = $cdesign->createUserLink(array('user' => $arOrders[$iCnt][iUserID])));

        $desText[2][text] = "<a href=\"$PHP_SELF?cmd=admin_orders&amp;page=details&amp;id=".$arOrders[$iCnt][id]."\">".$cxml->printString($lang['admin.overview.link.detail'])."</a>";

        $iTotalCost += $corder->getTotalCostOfOrdering(array('iOrderingID' => $arOrders[$iCnt][id]));

        $cl->TableText($desText);
        unset($desText);
      }

      (!$iCnt) ? (($in[0][colspan] = 3) && ($in[0][text] = $cxml->printString($lang['message.no_entries.3'])) && ($cl->TableText($in))) : (($desText[0][text] = $cxml->printString($lang['message.total_cost'],$iTotalCost." ".$cxml->printString($lang_def['money_sign']))) && ($desText[0][colspan] = 3) && ($cl->TableText($desText)));
      ($iCnt) ? ($cl->FormSubmit("3",$cxml->printString($lang['admin.ordersdone.form']))) : ($dummy);
    }
    elseif ($_GET['page'] == 'details')
    {
      (!$id) ? ($cfunc->faultExt($cxml->printString($lang_def['fault.missing.id']))) : ($dummy);

      $arOpts[id] = $_GET['id'];
      $arOrders  = $corder->getOrderings($arOpts);

      settype($iTotalCost,"double");

      $cl->cellsTop(array(array('text' => $cxml->printString($lang['admin.details.subject'],$cdesign->createUserLink(array('user' => $arOrders[0][iUserID]))), 'colspan' => '4')));
      $cl->TableText(array(array('text' => $cxml->printString($lang['admin.details.order_at']), 'colspan' => 2),array('text' => $cevent->convertTSToDB($arOrders[0][tsDate]), 'colspan' => 2)));
	  $cl->cellsDummy("4","out");
	  $cl->cellsTop(array(array('text' => $cxml->printString($lang['admin.details.article'])),array('text' => $cxml->printString($lang['admin.details.amount'])),array('text' => $cxml->printString($lang['admin.details.cost'])),array('text' => $cxml->printString($lang['admin.details.status']))));
      $arOrders = $corder->getOrderingRef(array('iOrderingID' => $_GET['id']));

	  $arStatus = $corder->getStatusTypes();
	  $arStatus['delete'] = $cxml->printString($lang['ar.1.delete']);

	  $cl->FormNew("$PHP_SELF?cmd=cmd_update&amp;action=setOrderDetails&amp;iOrderingID=".$_GET['id'],"");

	  for ($iCnt = 0;$iCnt<count($arOrders);$iCnt++)
	  {
	    $arArticle = $corder->getArticles(array('iArticleID' => $arOrders[$iCnt][iArticleID], 'bLoadAll' => 1));

	    if ($arArticle[0]['szExtArticleID'])
	    {
	      $arArticle[0][szName]  = $arArticle[0][szExtArticleID];
	      $arArticle[0][iCost]   = $lang_def['unknown'];
	      $bFoundTemplateArticle = 'true';
	    }

	    $cl->FormHidden("in_arIDs[]",$arOrders[$iCnt][iOrderingRefID]);
	    $desText[0][text] = $arArticle[0][szName];
	    $desText[1][text] = $arOrders[$iCnt][iAmount];
	    $desText[2][text] = $cfunc->tryAddFloatingPoints(($arOrders[$iCnt][iAmount] * $arArticle[0][iCost]))." ".$cxml->printString($lang_def['money_sign']);
	    $desText[3][text] = $cdesign->createSelectBox("in_iStatus_".$arOrders[$iCnt][iOrderingRefID],$arStatus,$arOrders[$iCnt][iStatus],$arNoopts);
	    $cl->TableText($desText);
	  }

      $szString = $cxml->printString($lang['admin.details.total_cost'],$cfunc->tryAddFloatingPoints($corder->getTotalCostOfOrdering(array('iOrderingID' => $_GET['id']))),$lang_def['money_sign']);
      ($bFoundTemplateArticle) ? ($szString .= $cxml->printString($lang['admin.details.add_cost'])) : ($dummy);

      $cl->TableText(array(array('text' => $szString, 'colspan' => 4)));
      $cl->FormSubmit("4",$cxml->printString($lang['admin.details.form.submit']));
    }
  }
  elseif ($_GET['cmd'] == 'admin_data')
  {
    (!$csecure->verifyUserForAdminArea(array('iUserID' => $_SESSION['active_userid'], 'area' => $PLUGIN_NAME))) ? ($cfunc->faultExt($cxml->printString($lang_def['fault.not_authorized']))) : ($dummy);

    $cdesign->newCreateTextTree($arNoOpts,
    		array(	$cdesign->createURLLink(array('szContent' => $cxml->printString($lang['admin.tree.overview.data']), 'bSkipCheck' => 1, 'bNoTarget' => 1)),
			  array(  $cdesign->createURLLink(array('absURL' => "$PHP_SELF?cmd=admin_data&amp;page=assistent", 'szContent' => $cxml->printString($lang['admin.tree.assistent']), 'bSkipCheck' => 1, 'bNoTarget' => 1)),
					  $cdesign->createURLLink(array('absURL' => "$PHP_SELF?cmd=admin_datas&amp;page=delete", 'szContent' => $cxml->printString($lang['admin.tree.delete']), 'bSkipCheck' => 1, 'bNoTarget' => 1)),
				    )
				   ));
  }
  elseif ($_GET['cmd'] == 'admin_assistent')
  {
	if (!$_GET['page'])
	  $_GET['page'] = 'start';

	if ($_POST['in_enumAction'])
	  $_GET['page'] = $_POST['in_enumAction'];


	$cl->cellsTop(array(array('text' => $cxml->printString($lang['admin.entry_assistent.subject.'.$_GET['page']]), 'colspan' => 2)));
	$cl->TableText(array(array('text' => $cxml->printString($lang['admin.entry_assistent.hint.'.$_GET['page']]), 'colspan' => 2)));

    // XML::CODE (Eingegebene Daten als Session-Variable verfügbar machen)
    $cl->parsePostString(array('szSpacer' => 'order_entries'));
    $arOpts = $cl->parsePostString(array('bDatabaseArray' => '1'));

    if ($_GET['page'] == 'start')
    {
	  $arActions['edit_category'] 	 = $cxml->printString($lang['ar.2.edit_category']);
	  $arActions['edit_orderservice'] = $cxml->printString($lang['ar.2.edit_orderservice']);

	  if (is_array($corder->getCategoriesAsHash(array('bLoadAll' => 1))) || is_array($corder->getOrderServicesAsHash(array('bLoadAll' => 1))))
	    $arActions['edit_article'] = $cxml->printString($lang['ar.2.edit_article']);

	  $cl->FormNew("$PHP_SELF?cmd=admin_assistent","");
      $cl->cells2Noopt($cxml->printString($lang['admin.assistent.action']),$cdesign->createSelectBox("in_enumAction",$arActions,$_SESSION['temp_order_entries_enumAction'],$arNoOpts),"out");

	  $cl->FormSubmit("2",$cxml->printString($lang['admin.entry_assistent.form.'.$_GET['page']]));
    }
    elseif ($_GET['page'] == 'edit_category')
    {
	  if ($_GET['action'] == 'submit')
	  {
	    if ($_GET['iCategoryID'])
	    {
	      $arTempOpts = $arOpts;
	      $arTempOpts['iCategoryID'] = $_GET['iCategoryID'];

	      if ($arOpts['bDeleteCategory'])
	      {
	        $corder->deleteCategory($arTempOpts);
	        $_SESSION['temp_order_entries_iCategoryID'] = '';
	      }
	      else
	        $corder->setCategory($arTempOpts);
	    }
	    else
	      $_SESSION['temp_order_entries_iCategoryID'] = $corder->addCategory($arOpts);
	  }

	  if ($arCategories = $corder->getCategoriesAsHash(array('bLoadAll' => 1)))
	  {
	    $arCategories[''] = $cxml->printString($lang['ar.3.new']);
	    $cl->FormNew("$PHP_SELF?cmd=admin_assistent&amp;page=edit_category","");
	    $cl->cells2Noopt($cxml->printString($lang['admin.assistent.load_settings']),$cdesign->createSelectBox("in_iCategoryID",$arCategories,$_SESSION['temp_order_entries_iCategoryID'],$arNoOpts),"out");
	    $cl->FormSubmit("2",$cxml->printString($lang['admin.assistent.form.load_settings']));
	    $cl->cellsDummy("2","");

	    if ($_SESSION['temp_order_entries_iCategoryID'])
	      $arCategory = $corder->getCategories(array('bLoadAll' => 1, 'iCategoryID' => $_SESSION['temp_order_entries_iCategoryID']));
	  }

	  $cl->FormNew("$PHP_SELF?cmd=admin_assistent&amp;page=edit_category&amp;action=submit&amp;iCategoryID=".$arCategory[0]['iCategoryID'],"");
      $cl->cells2Noopt($cxml->printString($lang['admin.category.name']),$cl->createInput(array('type' => 'text', 'name' => 'in_szName', 'value' => $arCategory[0]['szName'])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.category.desc']),$cl->createTextarea(array('name' => 'in_szDesc', 'value' => $arCategory[0]['szName'])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.orderservice.next_order']),$cevent->createPreSelectedDateMenu(array('timestamp' => $arCategory[0]['tsNextOrder'])).", ".$cevent->createPreSelectedTimeMenu(array('timestamp' => $arCategory[0]['tsNextOrder']))." ".$lang_def['time'],"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.category.bIsDeactivated']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bIsDeactivated', 'checked' => $arCategory[0]['szName'])),"out");

	  if ($arCategory)
	  {
        $arNewCategories = $arCategories;
        unset($arNewCategories[$arCategory[0]['iCategoryID']],$arNewCategories['']);

        if (!empty($arNewCategories))
          $cl->cells2Noopt($cxml->printString($lang['admin.category.delete_and_move']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bDeleteCategory'))." ".$cdesign->createSelectBox("in_iMoveToCategoryID",$arNewCategories,$_SESSION['in_iMoveToCategoryID'],$arNoOpts),"out");
	  }

	  $cl->FormSubmit("2",$cxml->printString($lang['admin.assistent.form.set_settings']));
    }
    elseif ($_GET['page'] == 'edit_orderservice')
    {
	  if ($_GET['action'] == 'submit')
	  {
	    if ($_GET['iOrderServiceID'])
	    {
	      $arTempOpts = $arOpts;
	      $arTempOpts['iOrderServiceID'] = $_GET['iOrderServiceID'];

	      if ($arOpts['bDeleteOrderService'])
	      {
	        $corder->deleteOrderService($arTempOpts);
	        $_SESSION['temp_order_entries_iOrderServiceID'] = '';
	      }
	      else
	        $corder->setOrderService($arTempOpts);
	    }
	    else
	      $_SESSION['temp_order_entries_iOrderServiceID'] = $corder->addOrderService($arOpts);
	  }

	  if ($arOrderServices = $corder->getOrderServicesAsHash(array('bLoadAll' => 1)))
	  {
	    $arOrderServices[''] = $cxml->printString($lang['ar.4.new']);
	    $cl->FormNew("$PHP_SELF?cmd=admin_assistent&amp;page=edit_orderservice","");
	    $cl->cells2Noopt($cxml->printString($lang['admin.assistent.load_settings']),$cdesign->createSelectBox("in_iOrderServiceID",$arOrderServices,$_SESSION['temp_order_entries_iOrderServiceID'],$arNoOpts),"out");
	    $cl->FormSubmit("2",$cxml->printString($lang['admin.assistent.form.load_settings']));
	    $cl->cellsDummy("2","");

	    if ($_SESSION['temp_order_entries_iOrderServiceID'])
	      $arOrderService = $corder->getOrderServices(array('bLoadAll' => 1, 'iOrderServiceID' => $_SESSION['temp_order_entries_iOrderServiceID']));
	  }

	  $cl->FormNew("$PHP_SELF?cmd=admin_assistent&amp;page=edit_orderservice&amp;action=submit&amp;iOrderServiceID=".$arOrderService[0]['iOrderServiceID'],"");
      $cl->cells2Noopt($cxml->printString($lang['admin.orderservice.name']),$cl->createInput(array('type' => 'text', 'name' => 'in_szName', 'value' => $arOrderService[0]['szName'])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.orderservice.next_order']),$cevent->createPreSelectedDateMenu(array('timestamp' => $arOrderService[0]['tsNextOrder'])).", ".$cevent->createPreSelectedTimeMenu(array('timestamp' => $arOrderService[0]['tsNextOrder']))." ".$lang_def['time'],"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.orderservice.phone']),$cl->createInput(array('type' => 'text', 'name' => 'in_szPhone', 'value' => $arOrderService[0]['szPhone'])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.orderservice.url']),$cl->createInput(array('type' => 'text', 'name' => 'in_absURL', 'value' => $arOrderService[0]['absURL'])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.orderservice.data']),$cl->createTextarea(array('name' => 'in_szData', 'value' => $arOrderService[0]['szData'])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.orderservice.bIsDeactivated']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bIsDeactivated', 'checked' => $arOrderService[0]['bIsDeactivated'])),"out");

	  if ($arOrderService)
	  {
        $arNewOrderServices = $arOrderServices;
        unset($arNewOrderServices[$arOrderService[0]['iOrderServiceID']],$arNewOrderServices['']);

        if (!empty($arNewOrderServices))
          $cl->cells2Noopt($cxml->printString($lang['admin.orderservice.delete_and_move']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bDeleteOrderService'))." ".$cdesign->createSelectBox("in_iMoveToOrderServiceID",$arNewOrderServices,$_SESSION['in_iMoveToOrderServiceID'],$arNoOpts),"out");
	  }

	  $cl->FormSubmit("2",$cxml->printString($lang['admin.assistent.form.set_settings']));
    }
    elseif ($_GET['page'] == 'edit_article')
    {
	  if ($_GET['action'] == 'submit')
	  {
	    if ($_GET['iArticleID'])
	    {
	      $arTempOpts = $arOpts;
	      $arTempOpts['iArticleID'] = $_GET['iArticleID'];

	      if ($arOpts['bDeleteArticle'])
	      {
	        $corder->deleteArticle($_GET['iArticleID']);
	        $_SESSION['temp_order_entries_iArticleID'] = '';
	      }
	      else
	        $corder->setArticle($arTempOpts);
	    }
	    else
	      $_SESSION['temp_order_entries_iArticleID'] = $corder->addArticle($arOpts);
	  }

	  if ($arArticles = $corder->getArticlesAsHash(array('bLoadAll' => 1)))
	  {
	    $arArticles[''] = $cxml->printString($lang['ar.5.new']);
	    $cl->FormNew("$PHP_SELF?cmd=admin_assistent&amp;page=edit_article","");
	    $cl->cells2Noopt($cxml->printString($lang['admin.assistent.load_settings']),$cdesign->createSelectBox("in_iArticleID",$arArticles,$_SESSION['temp_order_entries_iArticleID'],$arNoOpts),"out");
	    $cl->FormSubmit("2",$cxml->printString($lang['admin.assistent.form.load_settings']));
	    $cl->cellsDummy("2","");

	    if ($_SESSION['temp_order_entries_iArticleID'])
	      $arArticle = $corder->getArticles(array('bLoadAll' => 1, 'iArticleID' => $_SESSION['temp_order_entries_iArticleID']));
	  }

	  $cl->FormNew("$PHP_SELF?cmd=admin_assistent&amp;page=edit_article&amp;action=submit&amp;iArticleID=".$arArticle[0]['iArticleID'],"");
      $cl->cells2Noopt($cxml->printString($lang['admin.article.name']),$cl->createInput(array('type' => 'text', 'name' => 'in_szName', 'value' => $arArticle[0]['szName'])),"out");

	  if ($arCategories = $corder->getCategoriesAsHash(array('bLoadAll' => 1)))
	    $cl->cells2Noopt($cxml->printString($lang['admin.article.category']),$cdesign->createSelectBox("in_iCategoryID",$arCategories,$arArticle[0][iCategoryID],$arNoOpts),"out");

	  if ($arOrderServices = $corder->getOrderServicesAsHash(array('bLoadAll' => 1)))
	    $cl->cells2Noopt($cxml->printString($lang['admin.article.orderservice']),$cdesign->createSelectBox("in_iOrderServiceID",$arOrderServices,$arArticle[0][iOrderServiceID],$arNoOpts),"out");

      $cl->cells2Noopt($cxml->printString($lang['admin.article.cost']),$cl->createInput(array('type' => 'text', 'name' => 'in_iCost', 'value' => $arArticle[0]['iCost'], 'size' => '6'))." ".$lang_def['money_sign'],"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.article.desc']),$cl->createTextarea(array('name' => 'in_szDesc', 'value' => $arArticle[0]['szDesc'])),"out");
      $cl->cells2Noopt($cxml->printString($lang['admin.article.bIsDeactivated']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bIsDeactivated', 'checked' => $arArticle[0]['bIsDeactivated'])),"out");

	  if ($arArticle)
	  {
        $arNewArticles = $arArticles;
        unset($arNewArticles[$arArticle[0]['iArticleID']],$arNewArticles['']);
        $cl->cells2Noopt($cxml->printString($lang['admin.article.delete']),$cl->createInput(array('type' => 'checkbox', 'name' => 'in_bDeleteArticle')),"out");

        if (!empty($arNewArticles))
          $cl->cells2Noopt($cxml->printString($lang['admin.article.move']),$cdesign->createSelectBox("in_iMoveToArticleID",$arNewArticles,$_SESSION['in_iMoveToArticleID'],$arNoOpts),"out");
	  }

	  $cl->FormSubmit("2",$cxml->printString($lang['admin.assistent.form.set_settings']));
    }
  }
  // XML::COMMENT (Neue Einstellungen übernehmen)
  elseif ($_GET['cmd'] == 'cmd_update')
  {
    (!$csecure->verifyUserForAdminArea(array('iUserID' => $_SESSION['active_userid'], 'area' => $PLUGIN_NAME))) ? ($cfunc->faultExt($cxml->printString($lang_def['fault.not_authorized']))) : ($dummy);

    // XML::COMMENT (Allgemeine Einstellungen)
    if ($_GET['action'] == 'setSettings')
    {
      (($in_template_user) && (!$in_template_file)) ? ($cfunc->faultExt($cxml->printString($lang['fault.missing.template']))) : ($dummy);

      $cfunc->setSetting(array(key=>"lan.ordering.template.use",value=>$in_template_use));
      $cfunc->setSetting(array(key=>"lan.ordering.template.file",value=>$in_template_file));
      $cfunc->setSetting(array(key=>"lan.ordering.sendims",value=>$in_ordering_sendims));
      $cfunc->setSetting(array(key=>"lan.ordering.template.loaddbarticles",value=>$in_template_loaddbarticles));
      $cfunc->setSetting(array(key=>"lan.ordering.template.next",value=>$cevent->createTimestampFromMenu($arNoOpts)));
    }
    elseif ($_GET['action'] == 'setOrderDetails')
    {
      for ($iCnt = 0;$iCnt<count($_POST['in_arIDs']);$iCnt++)
      {
        $iID = $_POST['in_arIDs'][$iCnt];

        if ($_POST['in_iStatus_'.$iID] == 'delete')
          $corder->deleteOrderingRef($iID);
        else
        {
          if ($settings['lan.ordering.sendims'])
          {
            $arStatus = $corder->getStatusTypes();
            $arOrder = $corder->getOrderings(array('id' => $_GET['iOrderingID']));
			$arArticles = $corder->getOrderingRef(array('iOrderingRefID' => $iID));
			$szString = $arArticles[0][iAmount]." * ".$corder->getNameOfArticle($arArticle[0][iArticleID],$arArticle[0][iExtArticleID]);

            $cmsg->sendMessage("",
            					$corder->getUsernameOfOrder($_GET['iOrderingID']),
            					$cxml->printString($lang['update.ims_status_changed.subject']),
            					$cxml->printString($lang['update.ims_status_changed.body.2'],
            						$arStatus[$_POST['in_iStatus_'.$iID]],$cevent->convertTSToDB($arOrder[0][tsDate]),$szString,$corder->getTotalCostOfOrdering(array('iOrderingID' => $arOpts['id'])))
            					);
          }

          $corder->setOrderingRef(array('iOrderingRefID' => $iID, 'iStatus' => $_POST['in_iStatus_'.$iID]));
        }
      }
    }
    // XML::COMMENT (Bestellungen löschen)
    elseif ($_GET['action'] == 'doDeleteArticle')
    {
      $corder->deleteArticles($in_todel);
    }
    // XML::COMMENT (Bestellungen löschen)
    elseif ($_GET['action'] == 'doChangeOrderings')
    {
      for ($iCnt=0;$iCnt<count($in_arIDs);$iCnt++)
      {
        $szAction = ${"in_action".$in_arIDs[$iCnt]};
        $arOpts[id] = $in_arIDs[$iCnt];

        if ($szAction == 'del')
        {
          $corder->deleteOrdering($arOpts);
        }
        else
        {
          $arOpts[iStatus] = $szAction;
          $corder->setStatusOfOrder($arOpts);

          if (($settings['lan.ordering.sendims']) && (${"in_iLastStatus".$in_arIDs[$iCnt]} != $szAction) && ($szAction > '0'))
          {
            $arStatus = $corder->getStatusTypes();
            $arOrder = $corder->getOrderings(array('id' => $arOpts['id']));
			$arArticles = $corder->getOrderingRef(array('iOrderingID' => $arOpts['id']));

			for ($iCnt = 0;$iCnt<count($arArticles);$iCnt++)
			  $szString .= $arArticles[$iCnt][iAmount]." * ".$corder->getNameOfArticle($arArticle[$iCnt][iArticleID],$arArticle[$iCnt][iExtArticleID])."<br />";

            $cmsg->sendMessage("",
            					$corder->getUsernameOfOrder($arOpts[id]),
            					$cxml->printString($lang['update.ims_status_changed.subject']),
            					$cxml->printString($lang['update.ims_status_changed.body'],
            						$arStatus[$arOpts[iStatus]],$cevent->convertTSToDB($arOrder[0][tsDate]),$szString,$corder->getTotalCostOfOrdering(array('iOrderingID' => $arOpts['id'])))
            					);
            unset($szString);
          }
        }
        unset($arOpts);
      }
    }
    elseif ($_GET['action'] == 'deleteOrderings')
    {
      for($iCnt=0;$iCnt<count($_POST['in_arToDelete']);$iCnt++)
        $corder->deleteOrdering(array('id' => $_POST['in_arToDelete'][$iCnt]));
    }
    elseif ($_GET['action'] == 'doSetOrderlist')
    {
      for ($iCnt = 0;$iCnt<count($in_arIDs);$iCnt++)
      {
        if (${"in_ordered_".$in_arIDs[$iCnt]})
          $corder->setOrderingAsOrdered($in_arIDs[$iCnt]);
      }
    }
    printDanke();
  }
  else
  {
     faultExt($cxml->printString($lang_def['fault.not_registered']));
  }

  // XML::COMMENT (Seite abschließen)
  $cdesign->createSiteFooter($arOpts);
?>
Return current item: PhpChrystal - An Open Intranet System